Vim keyboard remap on Snow Leopard (MacOs 10.6)

keyboardkeyboard-layoutmac-osxosx-snow-leopardvim

I want to have my external keyboard's HOME, END, PAGEDOWN and PAGEUP working on Leopard's Terminal. So that I changed in Terminal > File > Preferences:

Home: \033[H  
End: \033[F  
PageUp: \033[5~  
PageDown: \033[6~  

It works 100% in command line – but it doesn't work while editing files in VIM.
Is there any possibility of remapping VIM keyboard in order to have these keys working?

Regards

Best Answer

If, according to the question, you already know the mappings, then it's easy..

Home: \033[H  
End: \033[F  
PageUp: \033[5~  
PageDown: \033[6~

Just edit ~/.vimrc and add:

map <Esc>[H <Home>
imap <Esc>[H <Home>
map <Esc>[F <End>
imap <Esc>[F <End>
map <Esc>[5~ <PageUp>
imap <Esc>[5~ <PageUp>
map <Esc>[6~ <PageDown>
imap <Esc>[6~ <PageDown>