How do I change the cursor shape for different Vim modes in the terminal?
Answer
:let &t_SI = "\e[6 q"
Explanation
Modern terminals support cursor shape changes via escape sequences. You can configure Vim to use a block cursor in normal mode, a thin line in insert mode, and an underline in replace mode — providing instant visual feedback about which mode you're in.
How it works
t_SI— escape sequence sent when entering Insert mode (Start Insert)t_EI— escape sequence sent when leaving Insert mode (End Insert)t_SR— escape sequence sent when entering Replace mode- Cursor shapes:
1/2= block,3/4= underline,5/6= bar (odd=blink, even=steady)
Example
" Block cursor in Normal mode, bar in Insert, underline in Replace
let &t_SI = "\e[6 q" " steady bar
let &t_EI = "\e[2 q" " steady block
let &t_SR = "\e[4 q" " steady underline
Normal mode: █ (block cursor)
Insert mode: | (thin bar)
Replace mode: _ (underline)
Tips
- For Neovim, use
guicursorinstead:set guicursor=n:block,i:ver25,r:hor20 - Works in most modern terminals: iTerm2, Alacritty, kitty, Windows Terminal
- Some terminals need
tmuxpassthrough:let &t_SI = "\ePtmux;\e\e[6 q\e\\" - Reset cursor on exit:
autocmd VimLeave * let &t_EI = "\e[6 q"