VIM:远离搜索边缘

dot*_*hen 2 vim search

我最近看到了一些VIM配置,其中搜索匹配将滚动到匹配后的N行,因此在搜索匹配下面将有N行,而不是在最后一行(为了给出上下文).我找不到提到这个的页面,显然我不知道google的正确关键字!

这个功能叫做什么,我怎么能使用VIM手册找到它,假设我不知道它叫什么?

谢谢.

Ste*_*ney 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
Run Code Online (Sandbox Code Playgroud)