Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restrict to visual selection (Enhancement) #4

Open
hlissner opened this issue Jun 5, 2015 · 2 comments
Open

Restrict to visual selection (Enhancement) #4

hlissner opened this issue Jun 5, 2015 · 2 comments

Comments

@hlissner
Copy link

hlissner commented Jun 5, 2015

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.

@braham-snyder
Copy link

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?

@hlissner
Copy link
Author

hlissner commented Dec 16, 2016

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants