简体   繁体   English

如何映射Meta键来控制vim中的键?

[英]How to map Meta key to control key in vim?

How do I map my Windows key (which is defined as the Meta_L key in Ubuntu) so that it also works as the Ctrl + L key in Vim? 如何映射我的Windows键(在Ubuntu中定义为Meta_L键),以便它也可以作为Vim中的Ctrl + L键使用? This is a more comfortable mapping for me in some circumstances. 在某些情况下,这对我来说是一个更舒适的映射。

You have to remap all the sequences which use <C-> to use <M-> and put them in the separate .vimrc. 您必须重新映射使用<C->所有序列以使用<M->并将它们放在单独的.vimrc中。

To receive the full list of current mappings use 要获得当前映射的完整列表,请使用

:redir > ~/mappings | map | redir END 
:e ~/mappings
:g!/<C-/d

After that you will have all the mappings that use key. 之后,您将拥有使用密钥的所有映射。 Add same mappings to your .vimrc substituting 将相同的映射添加到.vimrc替换中

:help map

It is not a one minute job but it is how it can be done. 这不是一分钟的工作,但它是如何做到的。

You can also go to System settings > Keyboard > and Alt/Win key behavior > Control is mapped to Alt keys, Alt is mapped to Win keys. 您还可以转到系统设置>键盘>和Alt / Win键行为>控制映射到Alt键,Alt映射到Win键。 This is much better to use control with thumb. 使用拇指控制要好得多。

Looks like Ctrl and Alt are hard-coded into in the Vim source. 看起来CtrlAlt在Vim源代码中被硬编码。 You can map your Windows key to Ctrl globally if you don't mind affecting all other programs too. 如果您不介意影响所有其他程序,可以将Windows键映射到全局Ctrl Some window managers will support doing this, or else you can use xmodmap . 一些窗口管理器会支持这样做,否则你可以使用xmodmap The Vim wiki has some info about mapping the Windows key to another Esc , which is similar. Vim wiki有一些关于将Windows密钥映射到另一个Esc的信息 ,这是类似的。

As an alternative to using xmodmap and if you're using GNOME, you can go into the Control Center → Keyboard Preferences → Layout Options → Alt/Win behaviour → Control is mapped to the Win Key. 作为使用xmodmap的替代方法,如果您正在使用GNOME,您可以进入控制中心→键盘首选项→布局选项→Alt / Win行为→控制映射到Win键。 (alternatively, run gnome-keyboard-properties ) (或者,运行gnome-keyboard-properties

Of course, this changes it for everything, not just vim. 当然,这会改变一切,而不仅仅是vim。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM