3

I have been a happy termite user for years, but that project was abandoned recently and superseded by alacritty. The problem is that a Vim session launched in alacritty ignores key combinations with Ctrl. At least Ctrl+End, Ctrl+Home, Ctrl+PgDown and Ctrl+PgUp are unresponsive.

I opened an issue at the alacritty repository, but it was closed by the developer. The reason being that these key combinations all function in neovim.

I would not like to learn another text editor already, been with vim for just over a year and has been a sizeable investment. Is there any way to get these key combinations functioning with alacritty?

Update: system set up is reported at the GitHub issue, but reproduced here for convinience:

  • Ubuntu 20.04
  • alacritty 0.7.2
  • vim 8.1
  • i3 4.17
8
  • 1
    Which version of Vim are you using? Note that NeoVim is for the most part compatible with Vim, so there's really not that much to learn...
    – filbranden
    Commented May 19, 2021 at 13:45
  • 1
    I can't reproduce this in my vim + alacritty (:nnoremap <C-Home> :echo "C-Home"<CR> worked fine)
    – D. Ben Knoble
    Commented May 19, 2021 at 15:52
  • 1
    And I can reproduce on my alacritty 0.8.0-dev: nnoremap <C-End> :echo 'hello'<CR> works in neovim but not in vim (not sure how to fix tho maybe you'll need to mess with t_kh? ¯\_(ツ)_/¯)
    – statox
    Commented May 19, 2021 at 16:05
  • 1
    @filbranden I updated the question with system set up. Commented May 20, 2021 at 13:20
  • 1
    @D. Ben Knoble could you share your set up? Commented May 20, 2021 at 13:20

1 Answer 1

2

The feature that makes key combinations such as the ones you mentioned is called modifyOtherKeys and it's provided by some terminals like xterm. It lets Vim distinguish various keys, like <C-i> from <Tab>, which used to be impossible.

Support for this feature was first introduced in Vim 8.1.2134, and the feature was enabled by default in version 8.1.2194. Starting from this version, when Vim thinks it's running in xterm (which it decides based on $TERM being xterm or xterm-256color or similar), Vim automatically sends the terminal a special sequence to enable the feature and request that the terminal start sending extended key codes which allow Vim to differentiate keys and capture all modifiers.

Ubuntu 20.04 LTS ships Vim 8.0.1453, which predates the introduction of this feature. So that explains why you had trouble getting it to work, even when setting the $TERM variable appropriately. (You probably got it to work in NeoVim since you got a recent version of NeoVim installed, which included the feature, so that part has a pretty plausible explanation too.)

My recommendation is that you upgrade the Vim package in your Ubuntu machine to a newer version. The easiest way to do so is to add a PPA which includes newer builds of the Vim package to your host. Luckily, there's a well maintained PPA with such Vim packages. In order to add it to your box, use the following commands:

$ sudo add-apt-repository ppa:jonathonf/vim
$ sudo apt-get update

And then you can use apt-get upgrade or similar to upgrade the Vim packages to the latest ones available from the PPA (version 8.2.2815 as of April 2021.)

1
  • This answer doesn't look right. I just checked, the default value of modifyOtherKeys is 0, and e.g. Ctrl+PageUp will send ^[[5;5~ regardless of modifyOtherKeys. modifyOtherKeys only affect e.g. Ctrl+I becomes ^[[27;5;105~ as you mentioned.
    – user202729
    Commented Feb 16, 2023 at 3:57

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.