|
|
发表于 2008-12-12 22:29:42
|
显示全部楼层
Post by acevery;1923083
谢谢,试了一下,感觉没有变化...难道是因为我原先就是回去最后编辑的一行?
另外,分享一下我的一个插件,每当你在插入模式下输到窗口最后一行的时候,自动把当前行卷到窗口中央 主要是用了几天emacs就这个功能和中文的段落重排比较满意,这个自动scroll实现比较简单,就自己动手加到vim里来了。
放到.vim/plugin下即可。
- " Filename: iautoscroll.vim
- " Author: Yu Yuwei <acevery@gmail.com>
- " Verson: 0.4
- " Last Modify: Dec 12, 2008
- " Function: Scrolling to center when cursor hit the last line in window
- " while inserting
- " Usage: in your ~/.vimrc, let g:IAutoScrollMode="<mode>", where <mode>
- " is "center" for scroll to center, or "top" for scroll to top,
- " "off" to disable this plugin.
- " Changlog:
- " 0.4: Dec 12, 2008
- " move the line and col check into if clause,
- " which is a little overhead before if :)
- " 0.3: Oct 06, 2008
- " fix logical error using "off"
- " move cursor to original place after scrolling
- " 0.2: Sep 20, 2008
- " support to scroll to top
- " ----------
- "
- if !exists("IAutoScrollMode")
- let IAutoScrollMode = "center"
- endif
- autocmd! CursorMovedI * silent call ICheck_Scroll()
- function ICheck_Scroll()
- " we only check scroll when enabled:)
- if g:IAutoScrollMode != "off"
- " first, get the line number in window
- let cursor_line_no = winline()
- " second, get the window height
- let winht = winheight(winnr())
- " if we hit the bottom, just move to center
- if cursor_line_no == winht
- " now store get the current line and column
- let cur_line = line('.')
- let cur_col = col('.')
- " OK, we are ready to move :)
- if g:IAutoScrollMode == "center"
- exec "normal zz"
- elseif g:IAutoScrollMode == "top"
- exec "normal zt"
- else
- exec "normal zz"
- endif
- " we need move cursor back to the original place,
- " otherwise insert mode in new line
- " would put cursor one space ahead.
- exec "call cursor(cur_line,cur_col)"
- endif
- endif
- endfunction
复制代码
EBUILD EBUILD :cool: |
|