2017-03-23 86 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.