evil-iedit-state
evil-iedit-state copied to clipboard
Restrict to visual selection (Enhancement)
We have 'iedit-restrict-function and 'iedit-restrict-current-line (even 'iedit-expand-down-a-line and 'iedit-expand-up-a-line), and iedit has 'iedit-restrict-region but it isn't interactive. It'd be nice to exploit evil's visual mode to restrict matches to a selected region.
I have an implementation of this in my emacs.d that maps SPC (in visual mode) to the following lambda:
(lambda ()
(interactive)
(if (iedit-current-occurrence-string)
(let ((current-prefix-arg '(4)))
(iedit-done)
(call-interactively 'iedit-mode)
(save-excursion (iedit-restrict-region (region-beginning) (region-end)))
(evil-previous-line))
(call-interactively 'evil-ret))))))
~~Unfortunately, while this does cut down on matches, it won't add new matches to an expanded restricted region (yet).~~
EDIT: Now it does, updated the lambda.
I can extract it into, say, a 'evil-iedit-restrict-region, for a PR if this interests you.
how difficult do you suppose it would be to make it an operator? i.e., evil-iedit-state/iedit-mode on a region or symbol, then, e.g., 3ap to restrict to matches of the original region or symbol within the next three paragraphs?
@braham-snyder I've taken this idea and since written evil-multiedit. The default config lets you visually select a region and press RET to restrict matches to that region. I can look into adding an operator to do that, it wouldn't be difficult.