输入一堆文本时,光标会被推向屏幕底部。我经常必须退出 INSERT 模式才能键入zz,这样 Vim才能将光标所在的行居中。我想要更自动的东西:例如,如果光标越过阈值(比如“屏幕中心线”下方的 5-8 行),Vim 会zz直接,而无需退出 INSERT 模式。
它可能会扰乱打字过程,但由于我要打字,我的眼睛会盯着屏幕,看到正在发生的事情。我认为退出 INSERT 模式更具破坏性。
是否有支持此用例的配置选项或插件?
您可以通过将 'scrolloff' 选项设置为一个较大的值来保持光标的行居中:
set scrolloff=999
Run Code Online (Sandbox Code Playgroud)
帮助页面中“滚动”的描述:
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).
Run Code Online (Sandbox Code Playgroud)