mpora
mpora

Reputation: 1479

Setting the cursor to a vertical thin line in vim

I am trying to set the cursor in insert mode to be a thin vertical line and I am unable to. I have tried this in my .vimrc file:

set guicursor+=i:ver100-iCursor

It does not set the cursor to a vertical bar on insert mode.

What am I missing and how do I do this?

Upvotes: 23

Views: 31864

Answers (4)

frmbelz
frmbelz

Reputation: 2553

I use iTerm2 on mac and none of the above worked. Silly (vim and interface ain't right) but works. To switch between vertical bar or box. Profiles -> Open Profiles... -> Edit Profiles... -> Text

enter image description here

enter image description here

enter image description here

Upvotes: 2

markroxor
markroxor

Reputation: 6506

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

Upvotes: 15

Eric Leschinski
Eric Leschinski

Reputation: 154113

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

Upvotes: 21

mpora
mpora

Reputation: 1479

This did the trick:

set guicursor=i:ver25-iCursor

I had to reduce the 100 to 25

Upvotes: 13

Related Questions