如何在 Vim 中的正常和插入模式之间更改光标? [英] How to change the cursor between Normal and Insert modes in Vim?
问题描述
如果可能,我想知道如何根据您所处的模式更改 Vim 中的光标(颜色、形状等).
I would like to know how to change, if possible, the cursor in Vim (in color, shape, etc.) depending on what mode you are in.
我总是忘记我没有处于插入模式并开始输入代码,这导致了各种疯狂的事情发生.如果光标上有某种视觉指示会很有帮助.
I am constantly forgetting that I am not in Insert mode and start typing code, which results in all sorts of crazy things happening. It would be helpful if there was some sort of visual indication on the cursor.
推荐答案
一种表示在插入模式之间切换的流行方法是切换 cursorline
选项,它负责是否当前屏幕行被突出显示(参见:help cursorline
):
A popular approach to indicate switching to and from Insert mode is
toggling the cursorline
option, which is responsible for whether
the current screen line is highlighted (see :help cursorline
):
:autocmd InsertEnter,InsertLeave * set cul!
或者:
:autocmd InsertEnter * set cul
:autocmd InsertLeave * set nocul
修改CursorLine
高亮组来改变样式根据您的喜好选择光标行(请参阅 :help :highlight
和:help highlight-groups
).
Modify the CursorLine
highlighting group to change the styling
of the cursor line to your liking (see :help :highlight
and
:help highlight-groups
).
这篇关于如何在 Vim 中的正常和插入模式之间更改光标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!