所有模式下的 Viper 模式

发布于 2024-08-13 05:39:10 字数 592 浏览 10 评论 0原文

我正在从 vi 转移到 emacs,并且使用 viper 和 vimpulse,当我 Cw Cw 到一个窗口并且无法使用相同的命令返回到原始窗口时,这会变得非常烦人,因为另一个缓冲区,这可能是一个帮助缓冲区,但不在 Viper 模式下。我该如何解决这个问题?

我尝试将其他模式添加到 viper 配置中,并使用钩子使它们默认以 viper 模式启动:

(add-to-list viper-vi-state-mode-list 'help-mode)
(add-hook 'help-mode (lambda () (setq viper-mode t)))

但这些命令都不起作用。事实上,第一个产生了以下错误:

Warning (initialization): An error occurred while loading `/home/konrad/.emacs.d/init.el':

Wrong type argument: symbolp, (fundamental-mode ...

除了 Cw Cw 之外,我还怀念无法使用 hjkl 进行导航的情况。有没有办法重用 viper 设置的键绑定,而不是为每种模式再次重新绑定它们?

I'm moving from vi to emacs and, using viper and vimpulse, it gets pretty annoying when I C-w C-w to a window and cannot get back to the original one with the same command because the other buffer, which could be a help buffer, is not in the Viper mode. How can I fix this?

I tried to add other modes to the viper configuration and make them start with the viper mode on by default using hooks:

(add-to-list viper-vi-state-mode-list 'help-mode)
(add-hook 'help-mode (lambda () (setq viper-mode t)))

But none of these commands did work. In fact, the first one yielded the following error:

Warning (initialization): An error occurred while loading `/home/konrad/.emacs.d/init.el':

Wrong type argument: symbolp, (fundamental-mode ...

Besides the C-w C-w, I also miss not being able to navigate using hjkl. Isn't there a way to reuse the keybindings set by viper, instead of rebinding them again for every mode?

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

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

发布评论

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

评论(2

幸福丶如此 2024-08-20 05:39:10

该错误是因为您忽略了引用变量viper-vi-state-mode-list,如下所示:

(add-to-list 'viper-vi-state-mode-list 'help-mode)

请参阅这个问题说明为什么需要引用'viper-vi-state-mode-list

但是,这并没有解决我的问题,这就是我如何让 Cw Cw 按照你想要的方式工作:

(define-key help-mode-map (kbd "C-w C-w") 'vimpulse-cycle-windows)

The error is because you neglected to quote the variable viper-vi-state-mode-list like so:

(add-to-list 'viper-vi-state-mode-list 'help-mode)

See this question as to why you need to quote 'viper-vi-state-mode-list.

But, that didn't solve the problem for me, this is how I got C-w C-w to work the way you want:

(define-key help-mode-map (kbd "C-w C-w") 'vimpulse-cycle-windows)
梦醒灬来后我 2024-08-20 05:39:10

将钩子添加到 help-mode 的语法如下所示:

(add-hook 'help-mode-hook (lambda () (viper-mode t)))

请注意,钩子变量以“-hook”命名,并且 setq 在这里不起作用,因为 viper-mode 是命令,而不是一个变量。

您也许可以获得所有模式来激活 viper:

(add-hook 'fundamental-mode-hook (lambda () (viper-mode t)))

因为所有模式都继承自基本模式。

The syntax for adding the hook to help-mode would look like this:

(add-hook 'help-mode-hook (lambda () (viper-mode t)))

Note the hook variable is named with "-hook", and setq doesn't work here because viper-mode is a command, not a variable.

You might be able to get all modes to activate viper with:

(add-hook 'fundamental-mode-hook (lambda () (viper-mode t)))

since all modes inherit from fundamental-mode.

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