Finally, I got my functional mappings by resorting to adding such mappings:
if has('mac') && ($TERM == 'xterm-256color' || $TERM == 'screen-256color') map <Esc>OP <F1> map <Esc>OQ <F2> map <Esc>OR <F3> map <Esc>OS <F4> map <Esc>[16~ <F5> map <Esc>[17~ <F6> map <Esc>[18~ <F7> map <Esc>[19~ <F8> map <Esc>[20~ <F9> map <Esc>[21~ <F10> map <Esc>[23~ <F11> map <Esc>[24~ <F12> endif
The answers to these questions were useful if you need to make sure that these escape sequences match your terminal or set your own:
display function keys in vim
Associate special keys as vim shortcuts
It probably depends on how the terminal emulators behave consistently (laughter), but @Mark Carey's suggestion was not enough for me (I would like it to be that simple). With iTerm2 in OS X, I already configured it for xterm-256color and tmux for screen-256color , but the functional mappings still won't work. Thus, has('mac') may not be necessary if these sequences from iTerm2 are xterm compatible, I have not tested it yet, so I left it in my own configuration for now.
You may need some versions of imap . Note that you should not use the noremap options, since you do want these mappings to be cascaded (to call everything you mapped to <Fx> ).
source share