Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create a mapping with control and a function key in Vim?

Tags:

vim

I would like to have a mapping to quickly quit all buffers, for use when I'm vimdiffing a lot of files. Control and a function key together proved a good safety, so that I don't accidentally hit this combination, unintentionally leaving Vim. I tried the following mapping:

map <C-F10> :qa<CR>

To no avail. If I ditch the control, I can quit with F10 alone—why doesn't control work with F10 in my mapping?

like image 709
Drew Stephens Avatar asked Nov 09 '09 20:11

Drew Stephens


People also ask

How do I remap a key in Vim?

To map a sequence of keys to execute another sequence of keys, use the ':map' command. For example, the following command maps the <F2> key to display the current date and time. The ':map' command creates a key map that works in normal, visual, select and operator pending modes.

What is Ctrl in Vim?

Because of Vim's modes, there is not a lot of holding down the Ctrl key while pressing another key. However ,in insert (or replace) mode, Ctrl + R will let you paste a register, and Ctrl + V lets you insert any character literally. Ctrl + W deletes a word, and Ctrl + H backspaces a letter.

Which command is used for mapping keys of a keyboard?

1 Answer. Explanation: The map command lets us assign the undefined keys or reassign the defined ones so that when such a key is pressed, it expands to a command sequence.

How do you call a function in Vim?

Calling A Function Vim has a :call command to call a function. The call command does not output the return value. Let's call it with echo . To clear any confusion, you have just used two different call commands: the :call command-line command and the call() function.


2 Answers

I suspect you are using vim and not gvim. vim keybindings are limited by the terminal we are running vim within.

I've given up on vim, and I systematically use gvim for that reason.

like image 127
Luc Hermitte Avatar answered Oct 04 '22 03:10

Luc Hermitte


Luc is right - I just tried that in gvim (well, MacVim) and it worked fine. Then I tried it in the terminal with no joy.

like image 40
Dr. Frankenstein Avatar answered Oct 04 '22 03:10

Dr. Frankenstein