VIM:远离搜索边缘

发布于 2025-01-04 01:39:01 字数 163 浏览 1 评论 0原文

我最近看到一些 VIM 配置,其中搜索匹配项会滚动到匹配项后面的 N 行,这样搜索匹配项下面会有 N 行,而不是在最后一行(以提供上下文)。我找不到提到这一点的页面,显然我不知道谷歌搜索的正确关键字!

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

谢谢。

I recently saw some VIM configuration where search matches would scroll to N lines past the match, so that there would be N lines below the search match instead of it being on the last line (to give context). I cannot find the page where this was mentioned, and apparently I do not know the right keywords to google for!

What is this feature called, and how could I have used the VIM manual to find it assuming that I don't know what it is called?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

喜爱皱眉﹌ 2025-01-11 01:39:01

据我所知,这不能仅用于搜索,而是一个可用于所有情况的设置。

您正在寻找 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

As far as I tell this can't be set just for search, but is a setting that will be used in all situations.

You are looking for scrolloff: Minimal number of screen lines to keep above and below the cursor. This will make some context visible around where you are working. sidescrolloff does the same thing but horizontally.

This is what I have in my .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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文