我从这里学到了http://kana.github.io/config/vim/surround.htmlyss 应该在当前行上运行,忽略前导空格。但在我的计算机上它总是包含前导空格,这看起来很糟糕。我使用的是 emacs 24.3。有什么想法吗?谢谢!
答案1
定义自己的 evil-text-object,一个带有空格修剪的行对象
以下是完整的设置(使用 evil 1.0.9- 测试):
(defmacro define-and-bind-text-object (key start-regex end-regex)
(let ((inner-name (make-symbol "inner-name"))
(outer-name (make-symbol "outer-name")))
`(progn
(evil-define-text-object ,inner-name (count &optional beg end type)
(evil-regexp-range count beg end type ,start-regex ,end-regex t))
(evil-define-text-object ,outer-name (count &optional beg end type)
(evil-regexp-range count beg end type ,start-regex ,end-regex nil))
(define-key evil-inner-text-objects-map ,key (quote ,inner-name))
(define-key evil-outer-text-objects-map ,key (quote ,outer-name)))))
;; trimmed line
(define-and-bind-text-object "l" "^ *" " *$")
上述代码在最新的开发版本上不起作用,我已经通知开发人员。https://bitbucket.org/lyro/evil/issue/478/new-text-object-created-from-regex-hang