Vim CursorLine color change in insert mode

前端 未结 5 411
天命终不由人
天命终不由人 2021-01-30 11:29

There is good snippet for changing cursor color:

if &term =~ \"xterm\\\\|rxvt\"
  \" use an orange cursor in insert mode
  let &t_SI = \"\\]12         


        
5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-30 11:52

    This is pretty straightforward, put the following in your .vimrc or custom colorscheme file.

    set cursorline
    autocmd InsertEnter * highlight CursorLine guifg=white guibg=blue ctermfg=white ctermbg=blue
    autocmd InsertLeave * highlight CursorLine guifg=white guibg=darkblue ctermfg=white ctermbg=darkblue
    

    For more information see:

    • :help 'cursorline'
    • :help :autocmd
    • :help InsertEnter
    • :help :highlight

    N.B: You can use the same method to change the colour of the cursor without all of those if-statements and escape-sequences (and this will also work in GVim).

提交回复
热议问题