The cursor of my gnome-terminal is an underline _.

I am using Neovim and I want the cursor in Command Mode to be: block |

set guicursor=n:block-Cursor

When I exit from Neovim I want the cursor back to underline. This is not happening. The cursor is staying as a block |.

Why isn't Neovim restoring the cursor back to the original one set for the terminal ?

Is there a plugin available to do that ? How do I do this ?

1 Answer 1


You can and add this to your init.vim:

augroup RestoreCursorShapeOnExit
    autocmd VimLeave * set guicursor=a:hor20
augroup END

See :h guicursor for details.

The reason it isn't done automatically is there's no way to query the terminal cursor shape

  • Why are you using such a complicated syntax ? Why not just use autocmd VimLeave * set guicursor=a:hor20 ? Why use augroup and what does autocmd! do ?
    – ng.newbie
    Commented May 5, 2020 at 19:31
  • 2
    Is to avoid duplicating the auto commands every time you source init.vim. autocmd!clears them. See a detailed explanation here
    – Tae
    Commented May 5, 2020 at 19:49
  • But my init.vim is only sourced once during startup. Right ? So what is the problem if I don't remove them ?
    – ng.newbie
    Commented May 6, 2020 at 6:25
  • Then you should be OK, although it’s common to manually source the init file when changed instead of starting a new instance. I even have an auto command for that. In any case, this particular auto command is so small that I think it is safe for you to try it without clearing it for a while
    – Tae
    Commented May 6, 2020 at 6:36
  • 1
    @Itachi you can add as many events as you want. See :help autocommand. In this case autocmd VimLeave,VimSuspend * set guicursor=a:hor20 should work
    – Tae
    Commented Apr 29, 2021 at 8: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.