Windows 键可以在 Vim 中映射吗?

发布于 2024-07-08 23:02:27 字数 59 浏览 9 评论 0原文

在 Emacs 中使用 Windows 键作为 Meta 非常有用,有没有办法在 Vim 中做到这一点?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

放低过去 2024-07-15 23:02:27

即使在终端中,您也绝对可以,尽管您必须将其用作元键(我发现无法单独使用它)。

使用 vim 编辑 .vimrc 文件。 假设您想在正常模式下重新映射 Win+q 以退出 vim。
只需添加您的映射,然后在尝试指示快捷方式时,按 Ctrl+V,然后按 Win+q

这会将类似于 ^X@sq 的内容添加到您的文件中(但不要直接键入^X 是一个 特殊字符)。

最后你的行应该是这样的:

nnoremap ^X@sq :q<CR>

保存并退出,再次启动 vim,就是这样。

注意:插入模式下的 Ctrl+v 按字面意思插入以下键/键组合。 有关更多信息,请在 vim 中尝试 :help i_CTRL-V

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.

非要怀念 2024-07-15 23:02:27

抱歉回答这么古老的问题,但解决方案非常简单:不可能在终端中使用 Win 键,但可以与 Gvim 一起使用它。 只需将其作为修饰符 T 传递即可。例如,

:nmap <T-F5> :q<cr> 

将 Win+F5 映射到 :q 命令。 但只能在*nix下使用。

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.

清眉祭 2024-07-15 23:02:27

您可以使用 AutoHotkey 将 windows 键映射 到其他键。 仅当 vim 处于活动状态时才激活映射:

#IfWinActive ahk_class GVIM
RWin::Alt  
LWin::Alt  
#IfWinActive  ; This puts subsequent remappings and hotkeys in effect for all windows.

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.
提赋 2024-07-15 23:02:27

这些答案(包括这个)都不是特定于 vim 的,所选答案是特定于 Windows 的。 这是 *nix 运行 X 的情况。

我将左 Win 键映射到 Esc 键。 这在虚拟终端中不起作用,但在 X 中有效。

要么:
(1) 将keysym Super_L = Escape追加到~/.Xmodmap并执行xmodmap .Xmodmap
|______(1a) ~与 echo "keysym Super_L = Escape" >> 相同 〜/.Xmodmap && xmodmap .Xmodmap .
(2) 执行 xmodmap -e "keysym Super_L = Escape" 。

如果您希望它在虚拟终端中工作,请参阅[0]。

参考文献:
[0] http://www.mail-archive.com/ [电子邮件受保护]/msg02859.html
[1] http://www.paganini.net/index.cgi/linux/ nocaps.html
[2] http://ubuntuforums.org/archive/index.php/t- 975229.html

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

醉酒的小男人 2024-07-15 23:02:27

不太确定,但 Ctrl+Esc 组合键是仅限 Windows 的键映射。 这对 vim 没有帮助

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文