yaronli
yaronli

Reputation: 705

How to map F1 to Ctrl+P in 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.

Upvotes: 4

Views: 3167

Answers (2)

Ingo Karkat
Ingo Karkat

Reputation: 172768

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>

Upvotes: 6

iMom0
iMom0

Reputation: 12931

try:

:imap <F1> <c-p>

Upvotes: 2

Related Questions