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

后端 未结 11 763
无人及你
无人及你 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:23

    If you are using tmux and iTerm2 on macOS,
    the following changes the cursor from a block to a cursor and highlights the current line

    if exists('$TMUX')
      let &t_SI = "\Ptmux;\\]50;CursorShape=1\x7\\\"
      let &t_EI = "\Ptmux;\\]50;CursorShape=0\x7\\\"
    else
      let &t_SI = "\]50;CursorShape=1\x7"
      let &t_EI = "\]50;CursorShape=0\x7"
    endif
    :autocmd InsertEnter * set cul
    :autocmd InsertLeave * set nocul
    

    credit: https://gist.github.com/andyfowler/1195581

提交回复
热议问题