Skip to content

Restrict to visual selection (Enhancement) #4

@hlissner

Description

@hlissner

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions