vimurxvt

Some key mappings for combinations with the PageUp/PageDown keys don't work


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>

Solution

  • 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.