Setting the cursor to a vertical thin line in vim

For gnome terminal version>3.15
Add this to your ~/.vimrc.

if has("autocmd")
  au VimEnter,InsertLeave * silent execute '!echo -ne "\e[2 q"' | redraw!
  au InsertEnter,InsertChange *
\ if v:insertmode == 'i' | 
\   silent execute '!echo -ne "\e[6 q"' | redraw! |
\ elseif v:insertmode == 'r' |
\   silent execute '!echo -ne "\e[4 q"' | redraw! |
\ endif
au VimLeave * silent execute '!echo -ne "\e[ q"' | redraw!
endif

You will get a block cursor in normal mode and a thin one in insert mode.

enter image description here


This did the trick:

set guicursor=i:ver25-iCursor

I had to reduce the 100 to 25


This code in my /home/el/.vimrc worked for my console:

if $TERM_PROGRAM =~ "iTerm"
    let &t_SI = "\<Esc>]50;CursorShape=1\x7" " Vertical bar in insert mode
    let &t_EI = "\<Esc>]50;CursorShape=0\x7" " Block in normal mode
endif

Which does this for me:

enter image description here

Source:

https://hamberg.no/erlend/posts/2014-03-09-change-vim-cursor-in-iterm.html

Tags:

Vim