如何重新映射前缀键 'c', 'd'在 Emacs viper 模式下等

发布于 2024-08-19 11:30:03 字数 322 浏览 5 评论 0原文

我正在使用 Colemak 键盘布局,并且想尝试 此处 与 Vimpulse 一起。然而,布局重新映射了命令前缀 Vim 键“c”和“d”等,并且这些键似乎不容易用标准 Viper 键重新映射命令重新映射。它们都映射到 viper 键盘映射中的“viper-command-argument”,实际的按键功能似乎是在 Viper 源代码的其他地方定义的。

有没有比分叉 Viper 源的本地副本并在其中重新定义魔术前缀键值更简单的方法将前缀命令重新绑定到其他键?

I'm using the Colemak keyboard layout, and want to try the Vim layout from here with Vimpulse. However, the layout remaps the command prefix Vim keys 'c' and 'd' among others, and these keys don't seem to be easily remappable with the standard Viper key remap command. They are all mapped to "viper-command-argument" in the viper keymap, and the actual key functions seem to be defined elsewhere in the Viper source.

Is there an easier way to rebind the prefix commands to other keys than forking my local copy of the Viper source and redefining the magic prefix key values within it?

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

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

发布评论

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

评论(2

赠意 2024-08-26 11:30:03

Viper 模式命令前缀键是通过两组间接设置的。您找到了第一个,因为所有命令键都绑定到 'viper-command-argument。接下来要做的就是在变量 viper-exec-array 中查找。目前的设置如下:

(aset viper-exec-array ?c 'viper-exec-change)
(aset viper-exec-array ?C 'viper-exec-Change)
(aset viper-exec-array ?d 'viper-exec-delete)
(aset viper-exec-array ?D 'viper-exec-Delete)
(aset viper-exec-array ?y 'viper-exec-yank)
(aset viper-exec-array ?Y 'viper-exec-Yank)
(aset viper-exec-array ?r 'viper-exec-dummy)
(aset viper-exec-array ?! 'viper-exec-bang)
(aset viper-exec-array ?< 'viper-exec-shift)
(aset viper-exec-array ?> 'viper-exec-shift)
(aset viper-exec-array ?= 'viper-exec-equals)

因此,如果您想让键 t 充当删除命令,您将需要以下两件事:(

(aset viper-exec-array ?t 'viper-exec-delete)
(define-key viper-vi-basic-map "t" 'viper-command-argument)

并且大概您会重新绑定来自 t 到某个地方,说出 c 键:

(define-key viper-vi-basic-map "c" 'viper-goto-char-forward)

最后,你必须修改例程 'viper-prefix-arg-com,我不这么做'话虽如此,如果将所有 ?c 替换为 ?t,那么 t 绑定将按预期工作。 (或者,您可以按照使用 ?c 的方式添加 ?t - 这也有效)。为此,但它有 100 行长,实际上不值得包含在此处(这是 4 个字符的更改)。您可以通过执行 Mx find-function viper-prefix-arg-com 来获取源代码。

长话短说,如果您想对 viper 的密钥进行批量重新绑定,这将是一项相当大的工作,并且您将更加熟悉 viper 源代码。

查看 'viper-prefix-arg-com 的编码方式,您无法在不重新定义它的情况下进行所需的更改。 viper-mode 可能实现了 3 或 4 个其他不同类型的 vi 命令(这个是“命令参数”)。其他人希望更直接地重新绑定......

Viper-mode command prefix keys are set up through two sets of indirection. You found the first, as in all the command keys are bound to 'viper-command-argument. The next thing that is done is a look up in the variable viper-exec-array. It is currently set like so:

(aset viper-exec-array ?c 'viper-exec-change)
(aset viper-exec-array ?C 'viper-exec-Change)
(aset viper-exec-array ?d 'viper-exec-delete)
(aset viper-exec-array ?D 'viper-exec-Delete)
(aset viper-exec-array ?y 'viper-exec-yank)
(aset viper-exec-array ?Y 'viper-exec-Yank)
(aset viper-exec-array ?r 'viper-exec-dummy)
(aset viper-exec-array ?! 'viper-exec-bang)
(aset viper-exec-array ?< 'viper-exec-shift)
(aset viper-exec-array ?> 'viper-exec-shift)
(aset viper-exec-array ?= 'viper-exec-equals)

So, if you want to make the key t act like a delete command, you would need the following two things:

(aset viper-exec-array ?t 'viper-exec-delete)
(define-key viper-vi-basic-map "t" 'viper-command-argument)

(And presumably you'd rebind the motion from t to somewhere, say the c key with:

(define-key viper-vi-basic-map "c" 'viper-goto-char-forward)

Lastly, you have to modify the routine 'viper-prefix-arg-com, which I don't pretend to fully understand. That being said, if you replace all the ?c with ?t, then the t binding works as expected. (Alternatively, you could add the ?t the same way the ?c is used - that works too). I'd provide the source for that, but it's 100 lines long, and not really worth including here (it's a 4 character change). You can get to the source by doing M-x find-function viper-prefix-arg-com.

Long story short, if you want to do a wholesale re-binding of the keys for viper, it's going to be a fair amount of work and you will become much more familiar with the viper source code.

Looking at the way 'viper-prefix-arg-com is coded, you cannot make the change you want without redefining it. There are probably 3 or 4 other different types of vi commands that viper-mode implements (this one being a 'command-argument). The others are hopefully more straightforward to rebind...

云裳 2024-08-26 11:30:03

看起来邪恶模式甚至支持重新映射命令前缀键。我会用它来代替。

It looks like Evil-mode supports remapping even the command prefix keys. I'll use that instead.

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