How do I change the cursor between Normal and Insert modes in Vim?

后端 未结 11 788
无人及你
无人及你 2020-12-04 10:56

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

11条回答
  •  悲&欢浪女
    2020-12-04 11:18

    If you are using a modern version of nvim and you wanted to achieve this, you can avoid some of these fancy workarounds listed above.

    The below settings will switch from block cursor in normal mode, to underline cursor in replace to line cursor in insert.

    # ~/.tmux.conf
    set -g default-terminal "screen-256color"
    set -ga terminal-overrides ",*256col*:Tc"
    set -ga terminal-overrides '*:Ss=\E[%p1%d q:Se=\E[ q',w
    
    
    " ~/.vimrc
    " Sets cursor styles
    " Block in normal, line in insert, underline in replace
    set guicursor=n-v-c-sm:block,i-ci-ve:ver25-Cursor,r-cr-o:hor20
    

    I managed to get this working with the following settings pulled from these two sources.

    tui-cursor-shape

    guicursor

提交回复
热议问题