Heinrich
Heinrich

Reputation: 289

Error in my Vim mapping

I would like to map Control + F3 with map <c-f3> :w <CR> :make <CR><CR><CR>. When I leave out the Control this works fine. With control from normal command mode insert mode is entered and 1;5R is inserted into the buffer.

When I use a simpler command e.g. map <c-f3> dd this works as expected.

With Shift instead of control I get a similar behavior (1;2R inserted into buffer). What can I do get my mapping right?

Edit: I want the command to be executed from normal command mode. However, vim enters insert mode, which is not desired.

Upvotes: 0

Views: 152

Answers (2)

Ingo Karkat
Ingo Karkat

Reputation: 172768

The combination of function keys and modifiers is problematic in terminal Vim; whether this works depends on the terminal.

  • Check your $TERM value; a wrong one can cause these problems. Also, your termcap database must be correct and complete.
  • Try out another terminal (gnome-terminal vs. konsole vs. xterm); it may work there.
  • Alternatively, use GVIM; it doesn't have these problems (but still can't map some other combinations).

If you use varying terminals, it's best to avoid these key combinations, and just use plain <F1..12>, and <Leader>... for the rest.

Upvotes: 1

Alex Kroll
Alex Kroll

Reputation: 481

map defines keystrokes for normal, visual and operation modes. For insert mode you should use imap. Something like this I believe: imap <c-f3> <esc>:w :make <cr><cr><cr>. <ESC> puts the Vim to normal mode.

:he :key-mapping for explaining.

Upvotes: 1

Related Questions