Vim change block cursor when in insert mode

10,095

Solution 1

I was connecting using iTerm on mac. It seems there is a setting in iTerm for it. Quick change and its working.

Solution 2

I know this is an old question but hopefully this will help anyone else facing the same scenario.

Actually I'm using iTerm2 and using Vim inside my terminal on Mac. And when entering to insert mode, the cursor still being a block and is kind of confusing when you are at insert mode or normal mode.

I wanted to show a thin line as cursor when in insert mode and back to block when in normal mode as MacVim does. And to do so it's pretty simple, just added this to my .vimrc file as described here:

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

enter image description here

But as you can see there was a delay when hitting ESC to exit insert mode back to normal mode and show the block as cursor again. So to fix it I found this:

set ttimeout
set ttimeoutlen=1
set listchars=tab:>-,trail:~,extends:>,precedes:<,space:.
set ttyfast

And now it works pretty fine as you can see:

fix delay going back to block as cursor

I hope it could help any one else! 👻

Solution 3

The gcr option does this, although I'm not sure exactly how it needs to be set to get the results you want.

:help gcr

If you read the manual and play around with it, you should be able to figure it out.

The blinking cursor in insert mode is usually the default. Maybe the gcr option got changed in your .vimrc

Share:
10,095
Derek Organ
Author by

Derek Organ

Founder of SaaS product for timesheet management. http://1timetracking.com Follow me on twitter http://twitter.com/jeebers

Updated on June 13, 2022

Comments

  • Derek Organ
    Derek Organ 3 months

    Not sure what the terminology is for it but on Vim the 'cursor' is always like an insert/replace cursor instead of the blinking line cursor I'm used to in other gui editors. Is there any way to change this when in insert mode?

    • Greg Hewgill
      Greg Hewgill over 11 years
      Are you using text mode Vim, or the GUI gVim?
    • Derek Organ
      Derek Organ over 11 years
      Vim on my remote machine using iterm.
    • Dennis Williamson
      Dennis Williamson over 11 years
      Please don't cross-post.
  • Chance
    Chance over 10 years
    What was the setting and where is it? I'm looking for this as well but not seeing it in iterm2
  • Alexandru Stana
    Alexandru Stana over 1 year
    It's a bit late, but maybe it helps someone hamberg.no/erlend/posts/…
  • Aidenhsy
    Aidenhsy over 1 year
    Thank you so much for this. Do you have any idea why my cursor doesn't flash? I am using vim on iTerm2 on Mac.
  • alexventuraio
    alexventuraio over 1 year
    @Aidenhsy maybe you need to activate this feature, go to Preferences > Profiles > Select you profile on the left side > Select Text tab on the right > Check Blinking cursor option. Hope it helps!
  • Dylan Landry
    Dylan Landry about 1 year
    For me, these &t_SI &t_SR &t_EI escape sequences didn't work, but the sequences in this answer did.