Reputation: 170919
Using Windows key as Meta is very useful in Emacs, is there the way to do it in Vim?
Upvotes: 18
Views: 17099
Reputation: 101
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.
Upvotes: 10
Reputation:
Not quite sure, but the Ctrl+Esc key combo is a windows only key mapping. It won't help with vim
Upvotes: 0
Reputation: 1139
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.
Upvotes: 7
Reputation: 14849
None of these answers (including this one) is vim-specific, and the selected answer is Windows-specific. Here's one for *nix running X.
I map my left Win key to the Esc key. This won't work in virtual terminals, but it works in X.
Either:
(1) Append keysym Super_L = Escape
to ~/.Xmodmap
and execute xmodmap .Xmodmap
.
|______(1a) ~same as echo "keysym Super_L = Escape" >> ~/.Xmodmap && xmodmap .Xmodmap
.
(2) Execute xmodmap -e "keysym Super_L = Escape"
.
If you want it to work in virtual terminals, see [0].
REFERENCES:
[0] http://www.mail-archive.com/[email protected]/msg02859.html
[1] http://www.paganini.net/index.cgi/linux/nocaps.html
[2] http://ubuntuforums.org/archive/index.php/t-975229.html
Upvotes: 5
Reputation: 15232
You can use AutoHotkey to map the windows key to a different key. Only activate the mapping when vim is active:
#IfWinActive ahk_class GVIM
RWin::Alt
LWin::Alt
#IfWinActive ; This puts subsequent remappings and hotkeys in effect for all windows.
Upvotes: 6