原生按键用户推荐 devil

尝试了一下把devil-mode和repeat-mode结合,感觉意外的还行

例如把常用的类似功能的命令放在一个repeatable的keymap里面,这样执行任意一个该keymap的命令的时候相当于无缝进入modal-mode,但是退出repeat-mode的时候还是需要支付一个额外按键的成本(C-g或者repeat-exit-key),例如我的配置:

(defvar-keymap ctrl-motion-map
  "f" #'forward-char
  "b" #'backward-char
  "n" #'next-line
  "p" #'previous-line
  "a" #'move-beginning-of-line
  "e" #'move-end-of-line
  "d" #'puni-forward-delete-char
  "k" #'puni-kill-line
  "t" #'transpose-chars
  "v" #'viper-scroll-up
  "V" #'viper-scroll-down
  "." #'repeat)

(keymap-set global-map "C-S-v" #'viper-scroll-down)

(defvar-keymap meta-motion-map
  "f" #'forward-word
  "b" #'backward-word
  "a" #'backward-sentence
  "e" #'forward-sentencne
  "k" #'kill-sentence
  "d" #'puni-forward-kill-word
  "t" #'transpose-words
  "y" #'yank-pop
  "^" #'delete-indentation)

(defvar-keymap structural-edit-map
  "f" #'puni-forward-sexp-or-up-list
  "b" #'puni-backward-sexp-or-up-list
  "u" #'backward-up-list
  "d" #'down-list
  "e" #'puni-end-of-sexp
  "a" #'puni-beginning-of-sexp
  "o" #'puni-expand-region
  "k" #'kill-sexp
  "t" #'puni-transpose
  "z" #'pop-to-mark-command
  "C" #'puni-convolute
  "R" #'puni-raise
  "S" #'puni-squeeze
  "<backspace>" #'backward-kill-sexp
  ")" #'puni-syntactic-forward-punct
  "(" #'puni-syntactic-backward-punct
  "]" #'puni-slurp-forward
  "[" #'puni-slurp-backward
  "}" #'puni-barf-forward
  "{" #'puni-barf-backward)

(define-keymap :keymap global-map
  "C-M-f" #'puni-forward-sexp-or-up-list
  "C-M-b" #'puni-backward-sexp-or-up-list
  "C-M-u" #'backward-up-list
  "C-M-d" #'down-list
  "C-M-e" #'puni-end-of-sexp
  "C-M-a" #'puni-beginning-of-sexp
  "C-M-o" #'puni-expand-region
  "C-M-k" #'kill-sexp
  "C-M-t" #'puni-transpose
  "C-M-z" #'pop-to-mark-command
  "C-M-C" #'puni-convolute
  "C-M-R" #'puni-raise
  "C-M-S" #'puni-squeeze
  "C-M-<backspace>" #'backward-kill-sexp
  "C-M-)" #'puni-syntactic-forward-punct
  "C-M-(" #'puni-syntactic-backward-punct
  "C-M-]" #'puni-slurp-forward
  "C-M-[" #'puni-slurp-backward
  "C-M-}" #'puni-barf-forward
  "C-M-{" #'puni-barf-backward)

(defun repeatize (keymap)
  "Add `repeat-mode' support to a KEYMAP."
  (map-keymap
   (lambda (_key cmd)
     (when (symbolp cmd)
       (put cmd 'repeat-map keymap)))
   (symbol-value keymap)))

(repeatize 'ctrl-motion-map)
(repeatize 'meta-motion-map)
(repeatize 'structural-edit-map)

这样每当我执行C-,M-或者C-M-作为prefix的命令时,repeat-mode启用,我只需要按一个键就可以执行对应keymap下的其他命令。

退出repeat-mode可以用:1 . C-g(或者,g)2. 按repeat-exit-key(我设置为了Return)3. 等待repeat-exit-timeout长的时间

小哥我有一个god-mode的fork,有没有兴趣试试,GitHub - YangZhao11/god-mode at struct 这个和upstream差的有点多了,要是有人有兴趣把他从新package一下就好了

键盘上有两个control键呢,怎么方便怎么来,单手双手都可以

试了下,init.el 里加了:

(require 'devil)
(global-devil-mode t)
(global-set-key (kbd "C-,") 'global-devil-mode)

但启动后不能直接用,比如 , x , f,必须按两次 C-, 后才能用

不明白

老哥我有个你的 god-mode 的 fork, 改了一个 bug 我记得是。