Can Windows key be mapped in Vim?

Deadly 提交于 2019-11-30 23:03:48

问题


Using Windows key as Meta is very useful in Emacs, is there the way to do it in Vim?


回答1:


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.




回答2:


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.



回答3:


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.




回答4:


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/screen-users@gnu.org/msg02859.html
[1] http://www.paganini.net/index.cgi/linux/nocaps.html
[2] http://ubuntuforums.org/archive/index.php/t-975229.html




回答5:


Not quite sure, but the Ctrl+Esc key combo is a windows only key mapping. It won't help with vim



来源:https://stackoverflow.com/questions/327415/can-windows-key-be-mapped-in-vim

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!