我们用中文输入法打出的 “”‘’ 其实英文符号,这些引号在 emacs 官方手册中常见。真正的中文引号是方的。
有现成的代码拷来即用:
;; @from https://github.com/syl20bnr/spacemacs/blob/c788da7/layers/%2Bdistributions/spacemacs-bootstrap/funcs.el#L81-L107
(defmacro spacemacs|define-text-object (key name start end)
"Define a text object and a surround pair.
START and END are strings (not regular expressions) that define
the boundaries of the text object."
`(progn
(spacemacs|define-text-object-regexp ,key ,name
,(regexp-quote start)
,(regexp-quote end))
(with-eval-after-load 'evil-surround
(push (cons (string-to-char ,key)
(if ,end
(cons ,start ,end)
,start))
evil-surround-pairs-alist))))
(defmacro spacemacs|define-text-object-regexp (key name start-regexp end-regexp)
"Define a text object.
START-REGEXP and END-REGEXP are the boundaries of the text object."
(let ((inner-name (make-symbol (concat "evil-inner-" name)))
(outer-name (make-symbol (concat "evil-outer-" name))))
`(progn
(evil-define-text-object ,inner-name (count &optional beg end type)
(evil-select-paren ,start-regexp ,end-regexp beg end type count nil))
(evil-define-text-object ,outer-name (count &optional beg end type)
(evil-select-paren ,start-regexp ,end-regexp beg end type count t))
(define-key evil-inner-text-objects-map ,key (quote ,inner-name))
(define-key evil-outer-text-objects-map ,key (quote ,outer-name)))))
;; 如果已经在用 spacemacs, 只要下边一句就可以了
(spacemacs|define-text-object "m" "quotation-mark" "“" "”")
然后按 csm" 就有效果了。@ziyuanjun