4

I want to customize the vim cursor to be a blinking rectangle block. I tried this and this and many other similar stuffs after some searches, but none of them works as expected.

Currently my cursor is an non-blinking underline in grey (i.e. the underline below character "e" in the last line below), which is pretty hard to recognize.

underline cursor

When the cursor is over a parenthesis character, it becomes a block. (Actually I believe this is a change in background color) What I want is to have this block all the time, and blinking.

block cursor

I have nothing related to cursor style in my .vimrc file. I am using Mac OS X 10.9, Terminal Version 2.4 (326), and oh-my-zsh. In Terminal settings, I use Pro theme and set cursor to underline. I can change this to block so the cursor in vim changes as well, but I need the underline cursor in a normal Terminal.

terminal settings

2 Answers 2

3

You can try this one in your .vimrc:

let &t_SI="\033[4 q" " start insert mode
let &t_EI="\033[1 q" " end insert mode

This will set under line for inset mode and block for normal. More details: http://vt100.net/docs/vt510-rm/DECSCUSR

Also it's possible to play with this command in terminal, where is X can be 0, 1, 2, 3 or 4.

printf '\033[X q'
1
  • The \033 escape character was the crux for me. The other suggestions using \<Esc>Ptmux;\<Esc>\<Esc> didn't work on OSX Terminal.app with Tmux, zsh, vim.
    – krry
    Feb 20, 2019 at 4:25
1

You may want to try adding this to your vimrc:

if exists('$TMUX')
    let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
    let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
else
    let &t_SI = "\<Esc>]50;CursorShape=0\x7"
    let &t_EI = "\<Esc>]50;CursorShape=0\x7"
endif

That should provide the correct escape sequences for tmux or iTerm.

I also found this plugin that auto changes the cursor based on the current mode.

2
  • 2
    It doesn't work. I use neither tmux nor iTerm. I am using the Terminal.app provided by Mac OS X and zsh.
    – Xiao Jia
    Feb 7, 2014 at 0:36
  • Found this post and am using tmux - works great thanks!
    – ostler.c
    Jun 9, 2014 at 18:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .