Today I Learned

hashrocket A Hashrocket project

Change Vim cursor in different modes

Vim's NORMAL mode and VISUAL mode are complemented perfectly by the block cursor. When in INSERT mode however, you might want a little more precision. That's why changing the cursor to a slim pipe shape is beneficial (you know, like in any textbox on your OS). It is also a nice reminder that you are in VISUAL mode, without having to stare at the bottom of the screen.

While we are at it, you might also want REPLACE mode to have a cursor of it's own, for that an underscore style looks great.

To accomplish this customization add the following to your .vimrc

iTerm2 + Tmux on OS

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>\\" 

iTerm2 on OS

let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_SR = "\<Esc>]50;CursorShape=2\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
See More #vim TILs
Every developer at Hashrocket is a Vim expert. Check out our development environment, Dotmatrix, and if you are in Chicago, come to the Vim Chicago Meetup hosted at our Chicago office.