Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to map several keys in Vim

Tags:

vim

macvim

How would I map ctrl+w+o to execute :Bonly<CR>?

I have tried

unmap <C-W>o
map <C-W>o :Bonly<CR>

Save file and source it with so %, but does not work.

like image 880
sites Avatar asked Jan 08 '13 03:01

sites


People also ask

How do I map a key in vim?

Creating keymaps 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. The ':map!'

What is XMAP in vim?

xmap creates a mapping for just Visual mode whereas vmap creates one for both Visual mode and Select mode. As far as I understand, the intent of Select mode was to make Vim behave just like every other non-modal editor when text is selected, i.e., typing anything immediately replaces the selection with the typed text.

Does vim allow for custom key bindings?

Creating a set of key bindings that is familiar, eases the learning curve of any new editor, and the flexibility vim allows in this configuration makes it easy to not only leverage the power of vim, but also make it feel like a familiar old friend.

What is the silent key in vim?

<silent> tells vim to show no message when this key sequence is used. <leader> means the key sequence starts with the character assigned to variable mapleader -- a backslash, if no let mapleader = statement has executed yet at the point nmap executes.


1 Answers

Your mapping (the :unmap is not necessary) should work with a sequence of Ctrl + W, followed by o.

If you want Ctrl + W followed by Ctrl + O, that'd be <C-w><C-o>.

In Vim, one can only map Ctrl / Shift / Alt combinations (and not all of them, unfortunately!) with a single key (like W). But there's a plugin that may help you achieve a mapping of all keys pressed simultaneously: arpeggio - Key mappings for simultaneously pressed keys

like image 109
Ingo Karkat Avatar answered Sep 24 '22 10:09

Ingo Karkat