I try to create a mapping for Alt < and Alt >:

inoremap <M-<> foo-bar-baz
inoremap <M->> baz-bar-foo

This doesn't work, most probably because < and > are themselves characters used to define the mapping. So, how can I create such a mapping?

  • I would say that pressing <Alt-<> and <Alt->> insert another character the one you would expected, so I could explain your issue... e.g. on my computer it insert respectivly ¯ and ˘
    – nobe4
    Aug 13, 2015 at 4:16
  • In insert mode, press Ctrl+V then Alt+<. What is inserted? Aug 13, 2015 at 22:16

1 Answer 1


As said in my comment, the <Alt-X> combination insert a special character. So instead of mapping to <Alt-X>, you can map it to the special character.


inoremap <M-<> foo-bar-baz
inoremap <M->> baz-bar-foo


inoremap ¯ foo-bar-baz
inoremap ˘ baz-bar-foo

Note : This was working on a Mac, on iterm2, tmux and macvim. The behaviour may change depending the configuration ...

Edit : You can look at those posts :

  • 2
    FYI, with xterm on Linux I get 0x1b 0x3e and 0x1b 0x3c With Alt+< and Alt+> (in other words, I get the expected Esc+key, instead of the MACRON and BREVE characters). Aug 13, 2015 at 9:00
  • @Carpetsmoker Depending on your keyboard settings, you may need to use <ALTGR> to type those letters. And you can also map them. With ALTGR i get 'ł€¶ŧ←↓→øþæßðđŋħł«»¢“”nµ·' (and others) that I can map to vim goodness. I can also get ' ̈́' but have managed to type UpperBar yet. Aug 13, 2015 at 20:07
  • 1
    @AlexStragies AltGr and Alt are different keys. Alt+character sends ESC followed by that character on most terminals, translated from the Alt+key keychord by the terminal emulator. AltGr+character inserts a different character which depends on the keyboard layout and is managed by the OS/GUI environment, not by the terminal emulator. Aug 13, 2015 at 22:19
  • @Gilles, I was aware of the ability to (exit Insert Mode+<CMDKEY>) with ALT-CMDKEY, because it sends <ESC> <CMDKEY>. I was trying to point out how to get many mappable characters with ALTGR. For me the 2 Keys from the OP example require ALTGR Aug 13, 2015 at 22:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.