简体   繁体   中英

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.

Also, is there a way in Vim to remove binding such as command+n (new window) and reassign that to something else?

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.

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. 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. 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 .

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. The help docs do much better at describing that then I could here.

I found a really good hack but it requires terminal 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>

I included a screenshot of the preferences tab in Iterm 2 for easy reference. Hope this helps someone.

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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