Using Windows key as Meta is very useful in Emacs, is there the way to do it 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.
I was delighted to learn that you can have your own key mappings in Vim. It is documented very well in the vim help section.
Use :map! and :map for manually set keys and :help 'char(-combination)' to find out which keys are already mapped in vim out-of-the-box(/out of your specific compiling options).
On vim , command-mode keys can be mapped through the ex command :map <key> <macro> and insert-mode keys can be mapped through :map! <key> <macro> . After mapped, the commands to remove the mapping from the command-mode keys and insert-mode keys are unmap <key> and unmap!
You definitely can, even in terminal, although you have to use it as a meta key (I found no way to use it on its own).
Edit your .vimrc file with vim. Say you want to remap Win+q
in normal mode to quit vim.
Simply add your mapping and, when trying to indicate your shortcut, press Ctrl+V
, then Win+q
.
This will add something similar to ^X@sq
to your file (but do not type it directly, the ^X
is a special character).
In the end your line should look like:
nnoremap ^X@sq :q<CR>
Save and quit, launch vim again, and that's it.
Note: Ctrl+v
in insert mode inserts followoing key/combination of keys literally. For more info try :help i_CTRL-V
in vim.
Sorry for answering so ancient question, but solution is really simple: it is impossible to use Win key in the terminal, but it is possible to use it with Gvim. Just pass it as modifier T. For example,
:nmap <T-F5> :q<cr>
will map Win+F5 to :q command. But it is usable only under *nix.
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