I notice that some of the evil around operators are greedy. As in they grab space around the surrounding delimiters. One such operator is the a".

Assuming that my cursor is | when I use va" the selection contains a whitespace around it. * denotes the beginning and end of the visual selection.

Adam said to Eve "Hello| World". ;; before
Adam said to Eve* "Hello World"*. ;; after

I realize this was done to emulate vim precisely, however, I find that in my editing this is far less useful than just selecting the delimiters and everything in the delimiters. I'd like to change all of these surround operators to match only until their delimiters. For evil-a-quote for example, I'd like the output the be what's shown below:

Adam said to Eve *"Hello World"*.

Hoping this would be as simple as changing a parameter, I checkout evil-a-double-quote.

(evil-define-text-object evil-a-double-quote (count &optional beg end type)
  "Select a double-quoted expression."
  :extend-selection nil
  (evil-select-quote ?\" beg end type count t))

Unfortunately setting :extend-selection to nil did not disable the greedy selection.

In the documentation I read that evil-select-quote returns (beg end) where beg and end are locations.

Right now my best idea is to replace evil-select-quote sexp with something like this:

(let ((beg (save-excursion (re-search-backward "\"")))
      (end (save-excursion (re-search-forward "\""))))
  (if (and beg end)
      (list beg end)
    (error "No matching delimiters found")))

Another idea is to surround the output of evil-select-quote in a while loop which will shrink the boundaries of the range by 1 character as long as the at least one of the boundaries is a whitespace character.

Both of these ways are doable but they seem like they could be a bit of work considering that I want to make all operators non-greedy, not just evil-a-quote.

Does anyone have a suggestion on how to do this simply?

  • Curious, I didn't know that a" included whitespace. The Vim manual says it includes trailing whitespace, or if there is none, leading whitespace. On the other hand the manual also says a( does not include whitespace outside the parenthesis. I'm sure there is a good reason for both behaviors... Maybe a( is designed for code and a" for prose? (Imagine what you'd usually want da" and da( to do.)
    – Omar
    Sep 20, 2018 at 12:49
  • Of course this is a workaround, but you might try expand-region. I use it successfully with Evil. (use-package expand-region :ensure t :bind ("C-=" . er/expand-region)) github.com/magnars/expand-region.el Nov 19, 2018 at 13:27

1 Answer 1


How you tried i" ? 'a' means with whitespace and 'i' means without ('inner'). I know this doesn't select the delimiters themselves, but that is quite rational IMHO.

  • 1
    Yes I like with inner selection. But I want an option that selects inner + delimiters without whitespace. Mar 24, 2018 at 9:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.