How can I map `Ctrl+Alt+Char` and `Ctrl+Number` in vim on Mac OSX?
1.Enviroment
Env: vim+zsh+iTerm2 on Mac OSX 10.9.2. (Same problems in macvim on Mac OSX 10.9.2)
2. Mapping Problem
In mac, mappings for <A-char>
won't directly work in mac.
:inoremap <A-u> type some string A-u
:inoremap <A-p> type some string A-p
:inoremap
i õ * type some string A-u
i ð * type some string A-p
As far as I know about <A-char>
in mac, hit <A-u>
will print nothing but with a sound alert. hit <A-p>
will print π
. I found that map for π
works well.
:inoremap π type some string A-p
Is it possible to map <A-u>
in vim? Yes!
Let me go into this problem deeply:
:map <A-S-p> not work
:map ∏ works well(A-S-p will print `∏`)
:map <C-A-p> not work
:map <C-π> still not work
:map <C-S-p> do work
:map <C-1> not work
So , is it possible to map Ctrl-Alt-char
and Ctrl+Number
?
Of course, you can use fastcodes in vimfastcodes in vim. Refer to https://stackoverflow.com/questions/23606892/vim-keyboard-mapping-problems-in-mac/23608928#23608928
Solution 1:
If you use MacVim, the easiest way is:
set macmeta
So that MacVim will treat alt/option as Meta key, you can then bind:
nmap <C-M-S> :call foo_func()
The keys pressed for above is: Ctrl+alt+s.
Hope this helps and solves your issue, happy Vimming!