Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make cursor show as vertical line in insert mode and as block in normal mode, in vim on iterm2

How to change vim cursor to vertical line in insert mode, and block in normal mode, iterm2. mac osx

I have tried some other configs, i found online which said it would fix it but none of them worked. I have tried this, from Vertical vim cursor in command mode:

let &t_EI = "\<Esc>]50;CursorShape=0\x7"
let &t_SI = "\<Esc>]50;CursorShape=1\x7"

I have also tried this one from this site https://hamberg.no/erlend/posts/2014-03-09-change-vim-cursor-in-iterm.html

if $TERM_PROGRAM =~ "iTerm"
    let &t_SI = "\<Esc>]50;CursorShape=1\x7" 
    let &t_EI = "\<Esc>]50;CursorShape=0\x7" 
endif

Nothing seems to be working, and the cursor still remains a block in both insert mode and normal mode. Is there anything else I can try?

like image 889
helloWorld12 Avatar asked Sep 18 '25 04:09

helloWorld12


1 Answers

There is all you need to know in this guide.

let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_SR = "\<Esc>]50;CursorShape=2\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"

If you use tmux:

let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
let &t_SR = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=2\x7\<Esc>\\"
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
like image 72
Benoît P Avatar answered Sep 19 '25 16:09

Benoît P