2

I have the following lines in my .vimrc for Ubuntu. They insert the current date as a string, and insert my signature at the bottom of the currently open file, respectively:

:map <F2> "=strftime("%B %d, %Y")<CR>Pli<Return><Esc>"
:map <F3> :e ~/.sign.txt<CR>ggV/^$<CR>k"*xG$a<C-R><C-O>*<Esc>:w<CR>:bd<CR>G$a<C-M><Esc>"*P

They're not working on my Macbook, though. The F2 command results in inserting "Q\n", and the F3 command results in inserting "R\n". How can I update these mappings to work on my Mac?

1

Put this in your .vimrc

" Mac specific fix for function keys
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>

From now on you can simply bind to <F1> for example

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .