0

Iedit-mode can narrow the edit to a region, I am using evil-mode, evil-visual-line select region by whole lines, after narrowing the point is at the end of last line, is it possible to fix this jumping and make it stay at the symbol's column? I have tried the following:

(defadvice iedit-mode (around iedit-around)
"fix cursor position"
(save-excursion ad-do-it))
(ad-activate 'iedit-mode)

1 Answer 1

1

Solution 1:

Since you use evil, check evil-mark-replace.

  • selected the region, then evilmr-tag-selected-region
  • move the cursor over the string to replace and evilmr-replace-in-tagged-region

Solution 2 (without evil):

select a region and my-iedit-restrict-selected-region:

(defun my-iedit-restrict-selected-region ()
  (interactive)
  (if (region-active-p)
    (iedit-restrict-region (region-beginning) (region-end))))

I suggest using solution 1 because it's much simpler and reliable.

1
  • iedit seems to have more functions, such as go to previous and next occurrence, and the region selection is not function specific, I mean you can call iedit and then use other packages to narrow the replace in a defun and called iedit again, so you don't need to make functions like evilmr-replace-in-defun and evilmr-replace-in-buffer.
    – godblessfq
    Jul 25, 2015 at 14:16

Your Answer

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

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