我最近看到了一些VIM配置,其中搜索匹配将滚动到匹配后的N行,因此在搜索匹配下面将有N行,而不是在最后一行(为了给出上下文)。我找不到提到这个的页面,显然我不知道google的正确关键字!
这个功能叫做什么,我怎么能使用VIM手册找到它,假设我不知道它叫什么?
感谢。
答案 0 :(得分:5)
据我所知,这不能只为搜索设置,而是一个将在所有情况下使用的设置。
您正在寻找scrolloff
:在光标上方和下方保留最少数量的屏幕线。这将使您可以在工作的地方看到一些上下文。 sidescrolloff
横向做同样的事情。
这就是我.vimrc
中的内容:
" When the page starts to scroll, keep the cursor 8 lines from the top and 8
" lines from the bottom and 15 lines on the left
set scrolloff=8
set sidescrolloff=15
set sidescroll=1