如何在 Vim 正常模式下交换键,而不仅仅是重新映射它们?
我使用 Dvorak,所以我的 .vimrc 中有以下内容:
no t j
no n k
no s l
no l n
no j t
no k s
它将方向键映射回主行的右侧。
这通常工作得很好,除了在插件中。例如,我无法在 NERDTree 插件中使用向上和向下导航,因为它会产生其他东西。
有没有办法让我不只是简单地重新映射按键,而是告诉 Vim 在正常模式下考虑将按 t 转换为按 j,无论上下文或插件如何?
我似乎隐约记得有一个 vim 命令可以将一个键别名为另一个键,但我找不到它。
I use Dvorak, so I have the following in my .vimrc:
no t j
no n k
no s l
no l n
no j t
no k s
which maps the directional keys to back to the right side of the home row.
This usually works quite well, except in plugins. For example, I can't navigate using up and down in the NERDTree plugin because it makes t something else.
Is there a way for me to, instead of simply remapping keys, tell Vim to consider a press of t in normal mode to be translated into a press of j, no matter what the context or plugin?
I seem to vaguely remember a vim command to alias one key to another, but I can't find it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我找到了我要找的东西:
I found what I'm looking for:
也许值得简单地了解德沃夏克琴键的位置。 hjkl 移动,但(恕我直言)不会以妨碍其有效使用的方式。 h 和 l 是右手的食指和小指,j 和 k 是左手的中指和食指。
重新映射你的大脑需要一段时间,但 Vi 键盘布局的大部分都是助记符,所以它比想象的要容易(例如,使用 emacs,恕我直言,它对德沃夏克相当敌对)。
It may be worth simply learning the Dvorak locations for the keys. hjkl move, but (imho) not in a way that prevents their efficient use. h and l are index and pinky on your right hand, j and k are middle and index on your left.
It takes a while to remap your brain, but much of the Vi keyboard layout is mnemonic so it is easier than it could be (e.g. with emacs which is pretty Dvorak hostile IMHO).