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
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-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))
nil did not disable the greedy selection.
In the documentation I read that
(beg end) where
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
Does anyone have a suggestion on how to do this simply?