例如,在线粘贴后,我的窗口显示文档的最右侧部分(列 >80)。
将光标留在当前位置后,如何将屏幕水平居中围绕它。或者,我可以将屏幕向左移动半个屏幕宽度,避免使用固定数字,例如44zh?
虽然标题不具体,但所有答案都只涉及向上/向下移动: 如何在 Vim 中移动屏幕而不移动光标?
omn*_*ron 14
我不知道如何围绕光标水平居中屏幕,但只要将屏幕向左/向右移动半个屏幕,试试这个(来自:help scroll-horizontal)
zL Move the view on the text half a screenwidth to the
right, thus scroll the text half a screenwidth to the
left. This only works when 'wrap' is off. {not in
Vi}
zH Move the view on the text half a screenwidth to the
left, thus scroll the text half a screenwidth to the
right. This only works when 'wrap' is off. {not in
Vi}
Run Code Online (Sandbox Code Playgroud)
我正在使用的一个不错的配置选项是sidescrolloff,它与scrolloff.
我目前在我的.vimrc中同时使用它们,这是我不能没有的设置。当然,您可以根据需要增加/减少偏移量。这有点取决于您正在处理的文档类型,我猜:)
set scrolloff=20 " keep 20 lines visible above and below cursor at all times
set sidescrolloff=30 " keep 30 columns visible left and right of the cursor at all times
Run Code Online (Sandbox Code Playgroud)
下面是来自 Vim 的一些信息:help
scrolloff光标上方和下方保持的最少屏幕行数。这将使您工作的地方周围的一些上下文可见。
sidecrolloff如果设置了 'nowrap',则要保留在光标左侧和右侧的最小屏幕列数。