2017-03-23 148 views
2

假设我刚刚在vim中用许多文本/代码行打开了一个文件。如何让vim在底部移动光标时自动滚动?

我用:150跳到第150行,然后我的光标停在屏幕的底部,我可能想知道接下来的几行代码是怎么样的。

我想知道一个设置,让vim的光标永远不会到达屏幕的最后4〜6行,而应该向上滚动文本。

这样的设置可能吗?

回答

3

使用

set scrolloff=6 

为6行滚动的偏移量。来自vim的帮助:

'scrolloff' 'so' number (default 0) 
      global 
      {not in Vi} 
    Minimal number of screen lines to keep above and below the cursor. 
    This will make some context visible around where you are working. If 
    you set it to a very large value (999) the cursor line will always be 
    in the middle of the window (except at the start or end of the file or 
    when long lines wrap). 
    For scrolling horizontally see 'sidescrolloff'. 
    NOTE: This option is set to 0 when 'compatible' is set.