开发者

Vim: How to exchange key bindings? (bind '|' on '7' key)

开发者 https://www.devze.com 2023-02-03 15:05 出处:网络
Having the German Mac Keyboard Layout, it is a pain to type | as it is bound to <A-7> and it is hard for me to reach the Alt key.

Having the German Mac Keyboard Layout, it is a pain to type | as it is bound to <A-7> and it is hard for me to reach the Alt key.

Thus, I'd like to do the following remapping (exchanging the binding for | 开发者_C百科and 7):

imap 7 <Bar>
imap <A-7> 7

The first one works, the second one does not. I have already tried all combinations with inor (no remap) but wasn't successful.

Maybe I don't get the concept of remapping. Or I am missing something else.


In my experience, some re-mappings that involve modifiers simply don't work in MacVim. The two workarounds I use are:

  1. Try a different modifier key, e.g. or

  2. Use Keyboard Maestro (an excellent key mapper for Mac OS X) to do the re-mapping


I think the answer you're looking for is:

inoremap 7 <bar>
inoremap <bar> 7

I use similar bindings to swap my semicolon and colon usage (except mine are not for insert mode):

nnoremap ; :
nnoremap : ;

xnoremap ; :
xnoremap : ;

Updated as per Rory O'Kane's suggestion in comments (thanks!).

0

精彩评论

暂无评论...
验证码 换一张
取 消