alacritty: Jumping word by word using control + arrow keys doesn't works in vim
Which operating system does the issue occur on? Arch Linux(Linux y50 4.13.12-1-ARCH #1 SMP PREEMPT Wed Nov 8 11:54:06 CET 2017 x86_64 GNU/Linux)
If on linux, are you using X11 or Wayland? X11
Usually, Pressing Ctrl+Left/Right arrow keys makes the cursor jump word by word in left or right direction in vim.
In alacritty, When I press Ctrl+Left Arrow Key, It enters :5D
in command mode in vim and pressing Ctrl+Right arrow key enters :5C
in command mode.
I tried fixes like putting set nocompatible
and set nocp
in my .vimrc
but it doesn’t works.
od -a
output for Left and Right arrow keys.
Left Arrow key -> ^[[1;5D
Right Arrow key -> ^[[1;5C
Is there some way to make arrow keys work in vim? I am not comfortable with using hjkl yet and not having arrow keys to help is slightly frustrating.
Thanks. PS: This project is awesome. I have a few suggestions and PRs, I’ll create seperate issues for those.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 9
- Comments: 26 (9 by maintainers)
Based on the discussion so far, this issue can be reproduced by base
vim
users who have theirTERM
environmental variable set asalacritty
and notxterm-256color
.This might be a naive (or bad) suggestion, but what about forcing
vim
to read your terminal asxterm-256color
as follows?This fixes the issue for me and has the simplicity of a one-liner, but not sure what side effects could arise.
The workaround I’m using is
(from https://superuser.com/a/402084/1182008)
This is better since it avoids having mappings starting with
<Esc>
, which would make vim wait fortimeoutlen
milliseconds whenever you press Escape.Workaround to add in .vimrc :
@chrisduerr That does indeed make it work. Renaming
alacritty
toxterm-256color
(main, common and direct) inalacritty.info
and installing withsudo tic -xe alacritty,alacritty-direct alacritty.info
. I verified it’s using the correct one (deleted allxterm
terminfo’s andinfocmp -x
).EDIT: Different name, as long as it starts with
xterm
also works, eg.xterm-alacritty
(butalacritty-xterm
does not). Possible solution?@jonpas can you try compiling alacritty’s terminfo file with
tic -x
? (you may want to wait for #2134 to land first.) In your configuration, alacritty doesn’t appear to definekDN5
,kLFT5
,kRIT5
andkUP5
, whereas xterm-256color does.However, using
tic -x
doesn’t work for me – I think Vim is hard-coding support for xterm here, c.f. the following bug (about the same issue in rvxt-unicode): https://bugzilla.redhat.com/show_bug.cgi?id=474110so there may be no solution in alacritty apart from pretending to be xterm. The real fix would need to be in Vim itself, I guess; IIUC, Vim would need to switch from using termcap to using terminfo.
See also
:help xterm-shifted-keys
:In addition to setting
<xUp>
,<xDown>
,<xRight>
,<xLeft>
, set'ttymouse'
tosgr
:Or clear
<DecMouse>
:If that doesn’t help, post the output of
:set! termcap
.Upstream fix. This already had to be done for some Neovim features.
The only solution is to open a bug upstream and resolve this in vim, since this is a vim bug, not an Alacritty bug.
@jonpas Would you mind trying to export Alacritty’s terminfo with the name
xterm-256color
? This might just be vim hardcoding something for xterm.The output of
od -a
in xterm(where arrow keys work just fine) is same as the output in alacritty.