2

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 ?

3

You can and add this to your init.vim:

augroup RestoreCursorShapeOnExit
    autocmd!
    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

| improve this answer | |
  • 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 May 5 at 19:31
  • 1
    Is to avoid duplicating the auto commands every time you source init.vim. autocmd!clears them. See a detailed explanation here – Tae May 5 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 May 6 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 May 6 at 6:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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