I haven't found a way to map it in gVim yet, but I was able to successfully map the Menu key in a urxvt
+screen
+vim
stack by the following method:
- In a terminal, type Ctrl+v and press Menu. This is mapped to the
quoted-insert
function in Zsh and in Readline-based tools like Bash.
- It will generate an escape sequence like
^[[29~
at the prompt. (The initial ^[
must be translated to <Esc>
for use in .vimrc
.)
- Open up
.vimrc
and add a line like this:
imap <Esc>[29~ <Esc>
(or imap <Esc>[29~ <Esc><Esc>
if you don't want it to wait for further input like the Escape key does.)
Note that not all keys return something usable from Ctrl+v. This is a limitation of terminal emulators and can be remedied by remapping the key. You may be able to do that at the level of the terminal emulator rather than for all X apps.
For example, for urxvt
, I had to add the following lines to ~/.Xresources
and run xrdb -merge ~/.Xresources
to apply them:
! Unbreak zsh keys in URxvt
URxvt*keysym.Home: \033[1~
URxvt*keysym.End: \033[4~
(\033
is <Esc>
in ~/.Xresources
syntax.)