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)
Drew
  • 75,699
  • 9
  • 109
  • 225
godblessfq
  • 1,177
  • 8
  • 21

1 Answers1

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.

chen bin
  • 4,781
  • 18
  • 36
  • 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 '15 at 14:16