In case it's relevant, this is on MacOS and iTerm.
How do I use key mappings that involve the Meta key, e.g. <M-e>
?
For example, the auto-pairs plugin has a keybinding that allows you to convert (|)foo
to (foo)
by pressing <M-e>
, where |
represents cursor position.
In iTerm > Preferences > Profiles > Keys
, I have the following options selected:
So whenever I pressed <M-e>
, the behavior becomes <Esc>e
. Note that changing the options to Normal
or Meta
in iTerm did not fix this issue.
In the end, I was only able to get this plugin command to work by adding the following to my .vimrc
: set <M-e>=^[e
, where ^[
is the escape literal achieved by pressing Ctrl-v
followed by Esc
.
In general, this is far from an ideal solution, since I'd having to manually set every single mapping involving Meta.
So my question is: how can I get all keybindings involving the Meta key to perform as expected, without needing to manually remap each individual instance?
<Esc>
. So, if you are using vim in a terminal emulator that is not supporting meta by default, you should not use meta. Otherwise you can adopt something that tpope did in vim-rsi plugin.