1

I use rxvt-unicode terminal emulator on Manjaro, and the following two mappings in my .vimrc don't work,

nnoremap <C-PageUp>   :tabprevious<CR>
nnoremap <C-PageDown> :tabnext<CR>

even though the following does work

nnoremap <C-t>        :tabnew<CR>
Enlico
  • 23,259
  • 6
  • 48
  • 102
Max
  • 817
  • 1
  • 10
  • 29
  • 1
    You know that you have `gt` and `gT` already, right? Anyway, what happens when you try using the first two mappings? – Enlico Apr 21 '20 at 08:18
  • @EnricoMariaDeAngelis hello, yes sure. But is doesn't work in insert-mode – Max Apr 21 '20 at 08:25
  • @EnricoMariaDeAngelis nothing, nothing happens. I change to and everything works with UpArrow – Max Apr 21 '20 at 08:29
  • 1
    Maybe it's related to [this](https://vi.stackexchange.com/questions/8461/shiftf8-changes-letter-case-for-2-letters-how-to-unmap-this), but I have no clue at the moment. I can try giving a look in the evening, because those mappings don't work for me either. – Enlico Apr 21 '20 at 08:31
  • @EnricoMariaDeAngelis ty! I will watch your link right now – Max Apr 21 '20 at 08:34
  • Besides, I suggest that you `set showcmd` in your `.vimrc` file and see what's shown on the last line on screen when you press those mappings; this will help you test the answer I linked (enter `:help showcmd` to know more about this option). – Enlico Apr 21 '20 at 09:06
  • Furthermore, if you enter `:help i_CTRL-`, you see that actually those mappings should work out of the box. – Enlico Apr 21 '20 at 09:16
  • Give a look at [Why do and not work in vim?](https://stackoverflow.com/questions/1814373/why-do-c-pageup-and-c-pagedown-not-work-in-vim). Does it solve the problem? – Enlico Apr 21 '20 at 17:11

1 Answers1

1

I think the reason for the behavior you observe is exactly the one described here.

In other words, something like this (what the rhs is doesn't matter)

nnoremap <C-PageUp> :echo "hello"<CR>

will not work as Vim does not now which escape sequence corresponds to the keycode <C-PageUp>.

Therefore, you can provide it with the escape sequence corresponding to Ctrl-PageUp, as in

nnoremap ^[[5^ :echo "hello"<CR>

where the first two characters of the escape sequence, ^[, are part of a single unit that corresponds to Escape (that's why escape seqeunce).

You can get the whole sequence (which could be different from mine in your terminal, by the way) from insert mode by hitting Ctrl+VCtrl+PageUp; however, given the meaning of ^[, you can also use Ctrl+VEscape and then type [5^ manually.

Unfortunately, putting set <C-PageUp>=^[[5^ causes error E518. I don't know why.

On the other hand, another solution is the following (again described here)

set <F37>=^[[5^
nnoremap <F37> :echo "ciao"<CR>

where <F37> is one of the extra function keycode Vim provides. I have no clue where this thing is in the :help.

Enlico
  • 23,259
  • 6
  • 48
  • 102