MacOS vim control+arrow functionality
Note: before doing any of this changes, make sure you back up your expse&spaces settings, terminal keyboard settings and .vimrc.
Being a fan of vim but unliking "gt" and "gT" to switch tabs and being used to do this by Control+arrows, raised a problem on MacOS.
The Linux .vimrc had simple commands:
- map <C-Up> :tabnew<CR>
- map <C-Down> :q<CR>
- map <C-Left> gT
- map <C-Right> gt
So first step, change this shortcuts:
System Preferences > Expose and Spaces > Spaces

Changing it to Control+Option+arrow is good enough.
But this still doesn't fix the problem, because the Control+arrow doesn't reaches to vim. To see how vim interprets a combination of keys, you can press Ctrl+v followed by that combination. The result of this is just the arrow key, like control isn't even pressed.
Luckily mac term allows us to change keyboard settings and we can set it act on control+arrow as we want.
In order to find the correct marking for the action, looking at Xterm Control Sequences sending control means "Esc ["; as for the arrow keys, up=A, down=B, right=C and left=D.
So the keyboard settings will look something like this:

But it still doesnt work.
That's because vim receives this serie of characters: Esc[A
This is where vimrc helps us. Instead of mapping <C-Up> we map <Esc>[A resulting in:
- map <Esc>[A :tabnew<CR>
- map <Esc>[B :q<CR>
- map <Esc>[D gT
- map <Esc>[C gt



Discussion
Yoo. You got Mac!
Welcome to the cult!
Yeah, thanks, got my mac and loving it from day one.
hehe, then you should probably check http://www.vicoapp.com/
Noroc!
@florin
Nice tut,
exactly what i was looking for !
Thx
Leave a Comment :
Leave a Comment