I want to change cursors to a | character in insert mode, and then back to a block in normal mode. I am using urxvt as my terminal, and neovim.

To switch cursors in my terminal, I run the following to get a blinking I-beam

echo -e "\033[5 q"

and then to go to a solid block:

echo e "\033[1 q"

I tried this in my vimrc:

let &t_SI = "\033[1 q"
let &t_SR = "\033[5 q"
let &t_EI = "\033[5 q"

but it didn't work. Nothing different from normal happens when I enter and exit insert mode.

I also tried this in my vimrc:

if has("autocmd")
  au InsertEnter * silent execute "!print -n -- '\033[1 q'"
  au InsertLeave * silent execute "!print -n -- '\033[3 q'"
  au VimLeave * silent execute "!print -n -- '\033[5 q'"

When I enter insert mode with this, the editor shifts up one line, and the status bar is shown twice at the bottom. When I exit insert mode, I see the text [3 q below the statusbar. Any ideas? Thanks

Some links that I tried:

https://bbs.archlinux.org/viewtopic.php?id=177281 https://bbs.archlinux.org/viewtopic.php?id=155802

1 Answer 1


Neovim does not use vimrc it uses $XDG_CONFIG_PATH/nvim/init.vim. Yet, there is more to it. In Vim you should use \<esc> to represent the escape key. I can change the cursor on Arch Linux on urxvt with the following in my vimrc:

let &t_SI = "\<esc>[5 q"
let &t_SR = "\<esc>[5 q"
let &t_EI = "\<esc>[2 q"

I also tried the autocmd technique and it works. Instead of the previous three lines I do:

au InsertEnter * silent execute "!echo -en \<esc>[5 q"
au InsertLeave * silent execute "!echo -en \<esc>[2 q"

And the cursor changes to a bar (|) in insert mode. In urxvt:

  • 1 is the blinky block cursor
  • 2 is the default (non-blinky) block cursor
  • 3 is blinky underscore
  • 4 fixed underscore
  • 5 pipe bar (blinking)
  • 6 fixed pipe bar

In neovim things work differently. Although :help termcap-cursor-shape is the same as in Vim it appears to ignore t_SI, t_SR and t_EI. As Caleb Eby found out the NVIM_TUI_ENABLE_CURSOR_SHAPE variable controls neovim's cursor shape instead.

You can therefore add:


To your ~/.config/nvim/init.vim and the cursor will work as if the termcap variables were set as:

let &t_SI = "\<esc>[5 q"
let &t_SR = "\<esc>[3 q"
let &t_EI = "\<esc>[2 q"

(But you cannot change the values, as far as I meddled with this)


  • I have my vimrc symlinked.
    – Caleb Eby
    Commented Aug 10, 2016 at 3:41
  • 1
    I got this to work in neovim by setting the environment variable NVIM_TUI_ENABLE_CURSOR_SHAPE to 1.
    – Caleb Eby
    Commented Aug 10, 2016 at 3:48
  • from hamberg.no/erlend/posts/…
    – Caleb Eby
    Commented Aug 10, 2016 at 3:48
  • @CalebEby - Wow, that's some pretty inconsistency in neovim. But yeah it appers to work well that way. I tested it a little and expanded the answer.
    – grochmal
    Commented Aug 10, 2016 at 5:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.