There are some keys I use in MacVim that terminal Vim doesn't recognize. For example, Ctrl-Enter, Shift-Enter, Ctrl-Space, Shift-Space, Ctrl-Backspace.
I'm using iTerm2, which lets you map keyboard shortcuts to send escape sequences. It seems like I could use this to make my desired key mappings work in the terminal. Something like,
iTerm2
Ctrl-Space: Send ^[[123;456ABC
Vim
set <F13>=^[[123;456ABC
map <F13> <S-Space>
noremap <S-Space> mzO<Esc>j`z
I'm not sure this will work, but I'm also wondering what I should be aware of before I start creating custom escape sequences willy-nilly. It seems like it could cause problems…
Best Answer
Between these 2 pages (below) I figured it out:
You stay "safe" by using the key codes for unused Function keys. In iTerm2, I created "keyboard shortcuts" that map the desired key-combos to the escape sequences for Function keys F13 through F16. Then, in my vimrc, I set Vim's keycodes appropriately, mapped the desired key-combos to the right Function keys, then mapped the same key-combos to whatever I want. I'm not sure I fully understand the direction things are flowing in, but it all gets linked up and works. Here's the relevant portion of my vimrc: