MacBook – “Home” and “End” HotKeys in Vim INSERT Mode with MacBook Pro

keyboardmacbook proterminal

I am pretty new to Vim and to Mac, I have a MacBook Pro with Retina Display running OS X 10.8.3, which does NOT have native Home, End, PageUp and PageDown keys.

I know the Fn + arrow keys can work in some applications. Also in bash, I can use Ctrl + A go to the beginning of the command line I am typing and Ctrl + E go to the end.

But in Vim with INSERT/edit Mode, all these works differently. I don't want to always switch to the Normal Mode using 0 and $ or I and A. (Or, is this the best way?)

So can anyone show me some tricks to map some hotkeys that can works conveniently? Or some other solutions? ( But please without MacVim, I want to try native Vim for a while first:) )?

Any other tips for Home, End, PageUp and PageDown functions under the Mac also welcome.

Best Answer

Go to Terminal -> Preferences -> Profiles -> Keyboard and add:

Key: ↖ Action: \033OH

Key: ↗ Action: \033OF