2

I'm using PuTTY as SSH client and zsh as a shell. When I just connect to a host and don't run nvim, I can see that control-left/right keys work correctly and send a different key from simply pressing an arrow by using ctrl-v:

# pressing ctrl-v left:
^[OD
# pressing ctrl-v ctrl-left:
^[[D

But when i run neovim :terminal, I get the same input no matter if I use control or not:

# pressing ctrl-v left:
^[OD
# pressing ctrl-v ctrl-left:
^[OD

Same thing when I just edit a file: In insert mode, ctrl-v ctrl-left inserts <Left> instead of <C-Left>.

This behavior is not reproduced with vim8, only with neovim.

The only way I managed to make it work correctly is by using tmux with options terminal-overrides "xterm*:kLFT5=\eOD:kRIT5=\eOC:kUP5=\eOA:kDN5=\eOB:smkx@:rmkx@" and default-terminal "screen-256color". However, I want to know how to make neovim correctly recognize ctrl-arrow keys without using tmux.

My values for $TERM are: xterm before starting nvim, xterm-256color inside nvim.

11
  • What is the value of environment variable $TERM as seen by neovim on the remote host? You can do :echo $TERM in nvim. (Value should be the same as your local setting as SSH carries it over.) Also, a long shot, but does toggling the "Disable application cursor keys mode" checkbox in Putty settings under Terminal>Features make any difference? (Change, then connect.)
    – B Layer
    Oct 1, 2019 at 3:04
  • 1
    BTW, have you considered alternative approaches to remote file editing? E.g. using local vim/scp, mounting remote dirs with sshfs, syncing remote files to local copies (with git or rsync, for example). I know people often have issues with the model you are using so I thought I'd mention some other ways they approach the problem.
    – B Layer
    Oct 1, 2019 at 3:55
  • I've added info about $TERM to the question. Oct 1, 2019 at 10:16
  • @BLayer Such approach won't cut it for me, because I have a remote server where I do my work, and I connect to it from various clients, some of which just happen to be Windows. I want to be able to attach/detach to my session with all terminal windows and processes at any time. Furthermore, it worked perfectly well with tmux, so I don't see a reason why it shouldn't work with pure nvim. Oct 1, 2019 at 11:06
  • I didn't mention alternatives as a workaround for this problem just as a general suggestion. Did you try toggling that Putty setting? It alters the control sequences sent by arrow keys (which might be handled differently app-to-app/terminal) so it should at least be ruled out as a cause.
    – B Layer
    Oct 1, 2019 at 15:32

0

Your Answer

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

Browse other questions tagged or ask your own question.