简体   繁体   English

重新映射左命令键到VIM中的领导者?

[英]Remap left command key to leader in VIM?

I have hand pain in my right hand. 我的右手有手痛。 I was hoping there was a way to map leader to the left command key. 我希望有一种方法可以将领导者映射到左命令键。 From what I've read this is not possible but perhaps there's a new plugin I'm not finding? 从我读到的内容来看,这是不可能的,但是也许找不到一个新插件?

If it's not possible to map to left command key, is it possible just to map to the command key? 如果无法映射到左命令键,是否可以仅映射到命令键? I tried let mapleader="<D>" and let mapleader="\\<D>" and this does not work. 我尝试了let mapleader="<D>"let mapleader="\\<D>" ,但这不起作用。

Also, is there a way in Vim to remove binding such as command+n (new window) and reassign that to something else? 另外,Vim中有没有办法删除诸如command + n(新窗口)之类的绑定并将其重新分配给其他东西?

The map Leader is designed to define a two key mapping. 地图负责人旨在定义两个键的映射。 In other words pressing one key and then the other within a timeout. 换句话说,在一个超时时间内按下一个键,然后再按下另一个键。 For example if leader were a then a map of <Leader>b would mean depressing a then depressing b in quick succession. 例如,如果leader是a那么<Leader>b的映射将意味着先后先按下a然后再按下b

The command key (and also meta, control, and shift) are all modifier keys and therefore do not register to the computer as a normal key press. 命令键(以及meta,control和shift键)都是修饰键,因此不会像普通键那样注册到计算机。 You would have to attach an actual key value to to a modifier for vim (or the system) to recognize that a key sequence was entered. 您必须将实际键值附加到vim(或系统)的修饰符上,才能识别出已输入键序列。 The closet you could get would be to have a modified key for the leader like :set mapleader=<Da> would produce a key sequence like <Da>b which seems more complex then simply ab . 您可以得到的壁橱是为领导者修改密钥,例如:set mapleader=<Da>会生成类似<Da>b的密钥序列,看上去比ab更复杂。

So no, there is no way for the leader setting to remove the two step mapping in lieu of a single step modified key. 因此,没有,领导者设置无法删除两步映射来代替单步修改键。

According to :help cmd-key of you want to reassign a command based mapping you first have to unbind it then reassign it. 根据您要重新分配基于命令的映射的:help cmd-key ,您首先必须解除绑定然后重新分配它。 The help docs do much better at describing that then I could here. 帮助文档在描述方面做得更好,然后我可以在这里进行描述。

I found a really good hack but it requires terminal vim. 我发现了一个非常好的hack,但是它需要终端vim。 If you use Iterm2 as I am, you can go into the preferences and map the left option key to do "Meta", now in vim just map it using let mapleader="\\<M> 如果按原样使用Iterm2,则可以进入首选项并映射左选项键以执行“ Meta”,现在在vim中,只需使用let mapleader="\\<M>

I included a screenshot of the preferences tab in Iterm 2 for easy reference. 我在Iterm 2中包括了“首选项”选项卡的屏幕截图,以方便参考。 Hope this helps someone. 希望这对某人有帮助。

在此处输入图片说明

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

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