18

Is it possible to map a vim command to a combination of keys involving more than one modifier? For example: ctrl-alt-v.

As far as I can tell, the only modifier key that can be used in combination with another is shift. e.g. <C-v> and <C-V>. Or am I missing something?

nelstrom
  • 18,802
  • 13
  • 54
  • 70

3 Answers3

16

Yeah, you would map <C-A-v> or <C-M-v> (A, Alt, and M, Meta are equivalent concepts). See :help key-notation.

ib.
  • 27,830
  • 11
  • 80
  • 100
chaos
  • 122,029
  • 33
  • 303
  • 309
  • 9
    This DOES NOT WORK in Macvim. Vim won't complain but modifiers after the first are ignored. So if you do `` for example, the shift is ignored. I can't say for other versions of vim. – Sean Mackesey Jul 21 '12 at 21:15
  • 2
    It doesn't work (for me, at least) in (normal, terminal-based) `vim` on a Mac either, so it doesn't appear to be specifically a MacVim issue, but rather an issue with `vim` on a Mac. – iconoclast May 07 '13 at 02:03
  • Odd. the help only mention Shift with the F keys, but not even that works for me. no modifier allowed with Fkey it seems. – gcb May 20 '14 at 23:49
  • To expand on @sean's comment - If you're using MacVim, see: [this superuser question](http://superuser.com/questions/280512/mapping-keys-in-vim-on-mac) – thom_nic Jun 24 '15 at 14:59
4

There's also this script (arpeggio) that allows you to use two or more simultaneously pressed keys (any keys, not just modifiers keys like shift, alt, etc.) in your mappings.

  • 3
    Cool, I love the name. Can I use it to play Bach? – nelstrom Sep 23 '09 at 21:46
  • Great plugin, very intuitive once it's set up. For example, I can type one bracket like normal then some code and then the closing bracket or I can just map `[]` to `[]` and hit them both at the same time ending up inside the brackets. Better yet, it saves on boilerplate, ie `Arpeggio inoremap pc biclass ea():` for python class. Thanks for posting! – Kyle G Apr 08 '12 at 00:15
1

They can be combined just fine, like this for example: <C-M-v> maps CTRL-Alt-v.

Meta (Alt) is M, Shift is S, and CTRL is C.

tobiasvl
  • 570
  • 4
  • 20