gpt4 book ai didi

plugins - 邪恶的 Emacs : is there a way to disable vim-like keys in «insert» mode?

转载 作者:行者123 更新时间:2023-12-04 02:22:38 27 4
gpt4 key购买 nike

我喜欢 VIM 的文本对象理念,所以我安装了 EVIL (模拟 VIM 功能的 Emacs 插件)。但我希望 «insert» 模式保持 Emacs 键绑定(bind)不变(也许 Escape 除外,它会切换到 «normal» 模式)。有什么办法可以实现吗?

顺便说一句:ATM «insert» 模式有一组混合的热键,这两种方式都不太舒服。例如。 «M-b» 与在 Emacs 中一样工作,而 «C-o» 与在 VIM 中一样工作。

最佳答案

#emacs IRC channel 我被告知someone already solved a similar problem .这是我使用的修改版本:

(require 'evil)
;; remove all keybindings from insert-state keymap
(setcdr evil-insert-state-map nil)
;; but [escape] should switch back to normal state
(define-key evil-insert-state-map [escape] 'evil-normal-state)
(define-key evil-normal-state-map (kbd "C-u") 'evil-scroll-up)
(define-key evil-normal-state-map (kbd "[ m") 'beginning-of-defun)
(define-key evil-normal-state-map (kbd "] m") 'end-of-defun)
(define-key evil-normal-state-map (kbd "k") 'evil-previous-visual-line)
(define-key evil-normal-state-map (kbd "j") 'evil-next-visual-line)

(evil-mode t)
(setq evil-jumps-cross-buffers nil) ;; for C-o and C-i to not cross buffers
(provide 'emvil)

(provide 'emvil) 允许在配置中require '。我还发现在下一个分屏中跳转到定义很有用,除非定义在我当前所在的缓冲区中。这是代码:

(defun evil-goto-definition-next-split ()
"If there's a free split, goto definition in this split,
otherwise use current one (except when a definition in the
current split)"
(interactive)
(let ((origin-spl (selected-window))
(origin-buf (current-buffer)))
(evil-goto-definition)
(when (and (eq origin-spl (selected-window)) ;; otherwise it's done
(not (eq origin-buf (current-buffer)))) ;; otherwise either definition not found, or
;; it's in the same buffer
(let ((defin-buf (current-buffer))
(defin-point (point)))
(switch-to-buffer origin-buf)
(other-window 1)
(switch-to-buffer defin-buf)
(goto-char defin-point)
))
))
(define-key evil-normal-state-map (kbd "g d") 'evil-goto-definition-next-split)

关于plugins - 邪恶的 Emacs : is there a way to disable vim-like keys in «insert» mode?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26572717/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com