1

I learned from here http://kana.github.io/config/vim/surround.html that yss should operates on the current line, ignoring leading whitespace. But it always includes the leading whitespace on my machine, which looks bad. I am using emacs 24.3. Any ideas? Thank you!

1 Answers1

0

define your own evil-text-object, a line object with spaces trimmed

Here is the complete setup (tested with 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" "^ *" " *$")

Above code does not work on latest dev version, I already notified the developer. https://bitbucket.org/lyro/evil/issue/478/new-text-object-created-from-regex-hang

chen bin
  • 469