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.
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!'
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.
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.
<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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With