Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to map F1 to Ctrl+P in Vim

Tags:

vim

I'm using the following command:

:imap <F1> ^P

to map F1 to Ctrl+P in the insert mode.

But it does not work.

like image 346
yaronli Avatar asked Oct 27 '25 20:10

yaronli


1 Answers

If that ^P is two characters, ^ and P, it's wrong. It has to be a single character (0x10), entered via CTRL-V CTRL-P (or CTRL-Q CTRL-P on many Windows versions of Vim, due to the remapping in mswin.vim).

Better completely avoid these issues by using the special notation <C-P>. Cp. :help keycodes

Oh, and when remapping built-in functionality, it's recommended to use noremap:

:inoremap <F1> <C-P>
like image 181
Ingo Karkat Avatar answered Oct 30 '25 20:10

Ingo Karkat