Bet Lamed
Bet Lamed

Reputation: 483

How do I change cursor key behaviour in the command line in neovim?

Currently, when I press cursor-left in the command line in neovim (:whatever foo bar), the cursor will move over a whole word. Most of the time, I just want it to move one character.

Upvotes: 0

Views: 544

Answers (2)

Bet Lamed
Bet Lamed

Reputation: 483

This has to do with putty and how it sends cursor keys. The trick is to find out what nvim actually sees, and then :cnoremap... accordingly.

The way to figure out what your nvim receives, is this:

  • enter input mode
  • hit ctrl-v
  • hit the key you want to see

Be aware that nvim behaves slightly differently than vim here: vim shows you the actual escape sequence, while nvim shows you the translated keys. The latter is a tad unfortunate.

In my case, for reasons I haven't figured out, nvim saw Ctrl-Left as , but Left as . Since I never need S-Left in the command line, :cnoremap <S-Left> <Left> did the trick.

Upvotes: 0

Martin Tournoij
Martin Tournoij

Reputation: 27842

This shouldn't be the default behaviour. It's probably a plugin or something you once added to your vimrc at some point. Try using :verbose cmap to see what it's set to (also see How do I debug my vimrc file?).

You should also be able to use :cnoremap <Left> <Left> to restore the default behaviour.

Upvotes: 1

Related Questions