如何在底部移动光标时让vim自动滚动?

时间:2017-03-23 12:32:33

标签: vim

我们假设我刚刚在vim中打开了一个包含多行文本/代码的文件。

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

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

这样的设置可能吗?

1 个答案:

答案 0 :(得分: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.