Vim:如何交换按键绑定? (将“|”绑定到“7”键上)

发布于 2024-10-10 21:17:15 字数 317 浏览 0 评论 0原文

使用德语 Mac 键盘布局,输入 | 很痛苦,因为它绑定到 并且我很难触及 Alt 键。

因此,我想进行以下重新映射(交换 |7 的绑定):

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

第一个有效,第二个无效。我已经尝试了与 inor 的所有组合(没有重新映射),但没有成功。

也许我不明白重新映射的概念。或者我还缺少其他东西。

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

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

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

发布评论

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

评论(2

最舍不得你 2024-10-17 21:17:16

根据我的经验,一些涉及修饰符的重新映射在 MacVim 中根本不起作用。我使用的两种解决方法是:

  1. 尝试不同的修饰键,例如 或

  2. 使用 Keyboard Maestro(适用于 Mac OS X 的优秀键映射器)来执行重新设置-mapping

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

围归者 2024-10-17 21:17:16

我认为您正在寻找的答案是:

inoremap 7 <bar>
inoremap <bar> 7

我使用类似的绑定来交换分号和冒号的使用(除了我的不用于插入模式):

nnoremap ; :
nnoremap : ;

xnoremap ; :
xnoremap : ;

根据 Rory O'Kane 在评论中的建议进行更新(谢谢!)。

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

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