victorhge / iedit Goto Github PK
View Code? Open in Web Editor NEWThis project forked from tsdh/iedit
Modify multiple occurrences simultaneously
Home Page: https://www.emacswiki.org/emacs/Iedit
This project forked from tsdh/iedit
Modify multiple occurrences simultaneously
Home Page: https://www.emacswiki.org/emacs/Iedit
mark-multiple is something similar to iedit: git://github.com/magnars/mark-multiple.el.git
My rectangle feature was "inspired" from mark-multiple. Iedit is much better for my uses, though.
It would be nice to have API to use iedit in a non-systematic way. For example this function:
iedit-mark(start, length)
This way another package can use Iedit to mark arbitrary parts of the buffer as master/mirror edits.
Running iedit-tests.el
with the current development branch ends up with 26 failing tests: https://gist.github.com/dunn/d2370dc951a2a2df3bdc
Is this an issue with Emacs 25, iedit, or my ert setup?
This stuff is very stateful, a table will help a lot. I'll add PR if I find the time to do it.
I tried to run tests on 24.2.1 and got:
Selector: t
Passed: 16
Failed: 7 (7 unexpected)
Total: 23/23
hi, im using evil
and the default key is not working. But when i do M-x iedit-mode
i get a text below the status bar saying " you can activate iedit-mode by C-;
"
When I try to use iedit in a buffer with flymake errors, flymake's overlay overrules iedit's match highlighting because it has a higher priority. I made the following change to fix it:
Index: iedit.el
===================================================================
--- iedit.el (revision 1784)
+++ iedit.el (working copy)
@@ -76,6 +76,11 @@
:type 'face
:group 'iedit)
+(defcustom iedit-overlay-priority 200
+ "The priority of the overlay used to indicated matches."
+ :type 'integer
+ :group 'iedit)
+
(defcustom iedit-current-word-default 't
"If no-nil, use current word by default for the occurrence."
:type 'boolean
@@ -271,6 +276,7 @@
(overlay-put occurrence 'insert-in-front-hooks '(iedit-occurrence-update))
(overlay-put occurrence 'insert-behind-hooks '(iedit-occurrence-update))
(overlay-put occurrence 'modification-hooks '(iedit-occurrence-update))
+ (overlay-put occurrence 'priority iedit-overlay-priority)
occurrence))
(defun iedit-make-unmatched-lines-overlay (begin end)
200 is a higher priority than highlight-current-line (60) and flymake (100) use, but lower than show-paren (1000) and auto-complete (9999) do.
(Excuse the svn diff format.)
As far as I understand the docs and source, there's no such feature yet, I wrote the following work-around:
;; Keep buffer-undo-list as is while iedit is active, that is, as long
;; as I am inside iedit I can undo/redo current occurences. However,
;; if I leave iedit and issue the undo command, ALL changes made with
;; iedit are undone, whereas the default behaviour would be to go
;; through every change made iside iedit, which I hate.
;; iedit doesn't provide a customizable flag to configure it's undo
;; behavior, so, I modify it myself using defadvice.
(setq my-buffer-undo-list nil)
(advice-add 'iedit-mode :before '(lambda (&rest args) ;; save current
(setq my-buffer-undo-list buffer-undo-list)))
(advice-add 'iedit-mode :after '(lambda (&rest args) ;; restore previously saved
(setq buffer-undo-list my-buffer-undo-list)))
Maybe this is of use for others, therefore I'm posting it here.
Thanks for iedit anyway, I LOVE LOVE LOVE it 👍
Hello,
What is the difference with https://github.com/magnars/multiple-cursors.el ?
diff --git a/iedit-lib.el b/iedit-lib.el
index 636c0bb..a7d92b0 100644
--- a/iedit-lib.el
+++ b/iedit-lib.el
@@ -194,9 +194,10 @@ Return the number of occurrences."
(save-excursion
(goto-char beg)
(while (re-search-forward occurrence-regexp end t)
- (push (iedit-make-occurrence-overlay (match-beginning 0) (match-end 0))
- iedit-occurrences-overlays)
- (setq counter (1+ counter)))
+ (unless (text-property-not-all (match-beginning 0) (match-end 0) 'read-only nil)
+ (push (iedit-make-occurrence-overlay (match-beginning 0) (match-end 0))
+ iedit-occurrences-overlays)
+ (setq counter (1+ counter))))
(message "%d matches for \"%s\"" counter (iedit-printable occurrence-regexp))
(when (/= 0 counter)
(setq iedit-occurrences-overlays (nreverse iedit-occurrences-overlays))
you can check out
(wdired-isearch-filter-read-only) in wdired.el or
query-replace-skip-read-only in replace.el
I'm trying out the M-M (switch to multiple cursors) binding and it always fails for me with:
iedit-switch-to-mc-mode: Invalid function: mc/save-excursion
I'm not sure what's wrong, `mc/save-excursion' is defined:
mc/save-excursion is a Lisp macro in ‘multiple-cursors-core.el’.
I've try (global-set-key [(control ?\;)] 'iedit-mode)
and (require 'iedit)
;
and neither of them make the keybinding C-;
work correctly.
And i am using Emacs in X-windows.
The keybinding C-;
only show something looks like pop-tip, and the "pop-tip" got all the content of clipboard on it - shows by a list that have a number before every item , i can press the number to choose one item and it will be paste to Emacs's buffer ...
I've try remove all the package , and C-;
shows the "pop-tip" too , i don't know to make C-;
work for iedit
Hi Everyone,
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?
To reproduce:
result: only one of the buffers is actually updated, the rest are not.
I think it is because of this:
https://github.com/victorhge/iedit/blob/master/iedit.el#L828
the modification hooks are disabled, and multi-occur depends on them to update the files.
EXAMPLE: I have the following text in the buffer -
This is
When I put the cursor between i and s and then press <C-;>, there is an error called "0 matches for http://is".
Anybody knows what is the cause for this? (My emacs version is 23.1.1)
Thanks!
It's a bug to not be sensitive to transient-mark-mode
. That's the fundamental premise of enabling this minor-mode. The user is indicating that the region he's interested in will always have the mark active and be highlighted.
Emacs already has built-ins that respect this -- region-active-p
. Why not just use that?
First of all, let me say thanks to everyone who contributes to iedit.
I ran into this problem after installing another package that depends on iedit. I have a keybind under C-;
, and after an upgrade today I was perplexed to find it had been overriden by a mode which I've never used before.
The keybinding convention recommends "C-c followed by any other punctuation character" for minor modes. But mostly, it was just confusing to find such a low-level key overriden.
Could you check whether the key is not already taken before binding it?
Best,
Hi there, emacs noob reporting in.
How do I go about installing this?
Hi everyone,
In some buffer "-" is treated as a seperator, and I can't edit symbol like "hello-world" as a whole, it would be nice if I select a region and do edit on all instance of that region in the buffer.
Thank you for your consideration!
I have no idea why but in some functions/methods, M-0 C-;
fails with Wrong type argument: overlayp, nil
.
How could I provide more information about this bug?
I'm using the latest HEAD
on Emacs 24.2 on OS X 10.7.
Hello,
in the gui version of Emacs, hitting the tab key after entering "iedit-mode" doesn't call "iedit-next-occurrence" but the global binding of tab. Works in terminal however. This helps:
(define-key iedit-lib-keymap [tab] 'iedit-next-occurrence)
Can we please fix this in the source? Thanks.
Hi,
First, thanks for iedit -- I've only recently started using it (as part of spacemacs) but I find it very useful.
Here's the issue I'm having. If I execute the following sequence of commands:
iedit-restrict-current-line
iedit-expand-up-a-line
iedit-expand-down-a-line
iedit-expand-down-a-line
the search range will be -1/+2.
If I then do
iedit-restrict-current-line
again, the search will be restricted to the current line. But if I then do
iedit-expand-up-a-line
the search range will be -2/+2; i.e., the range counters weren't reset.
I'm aware I can use a prefix argument to reduce the range, but this is awkward, and the current behavior is (to me at least) very unintuitive.
A simple fix for this would be to modify iedit-restrict-current-line
so that it sets the range counters to 0. I can put together a PR with this change if it sounds acceptable.
First, thanks for the awesome tool.
I've got a problem where I want to modify the occurrences of some text with special characters inside a string. It works correctly in the scratch buffer, but in a .cpp file, it does not.
Consider the following text:
printf("some @special text");
string special = "more @special text");
In the scratch buffer, if I press C-; when the cursor is on the "c" in @special (in the first line) it correctly only highlights "@special" in both lines.
However, in a C++ buffer, the same action results in only "special" (without the @) being highlighted, and it highlights all three occurrences of the string. This occurs even if I have already defined a region that contains the @ sign prior to pressing C-;
Attached is an init.el file that reproduces the behavior.
init.el.zip
;; - With digit prefix argument 0, only occurrences in current function are matched
Hi, i use iedit for a long time ... but i never remember this C-u 0 C-;
binding ...
I am wonder why add a extra 0
to this binding?
when i use iedit, i only remember C-;
and some times to try C-u C-;
, but never
try C-u 0 C-;
...
so , i thought, this 0
is not necessary, maybe we could add a C-u C-;
support?
Thanks.
I mapped iedit-mode to "C-i" globally.
(define-key global-map (kbd "C-i") 'iedit-mode)
Now when I press that key "C-i", it gets me to iedit-mode alright. But when I press the combination again it doens't turn off iedit-mode. It basically functions as iedit-next-occurance ? Am I missing something?
Windows 10, Emacs 25.1, package iedit
Suppose I has text:
1.aaa_1111_hello
2.aaa_2222_hello
3.aaa_1111_hello
4.aaa_4444_hello
5.aaa_1111_hello
6.aaa_5555_hello
7.aaa_1111_hello
8.aaa_1111_hello
...
100.aaa_1111_hello
I want to replace all (100 lines) "_1111" by text "_zero"
Steps:
Select text "_1111"
1.M-x iedit-mode
2.M-D
(to delete all find text _1111)
3.Input new text _zero
Here result.
1.aaa_zero_hello
2.aaa_2222_hello
3.aaa_zero_hello
4.aaa_4444_hello
5.aaa_zero_hello
6.aaa_5555_hello
7.aaa_zero_hello
8.aaa_zero_hello
...
100.aaa_zero_hello
OK.
But now I want to replace text ONLY from line "5.aaa_1111_hello" and to the end down.
So as result I need to replace 98 lines.
The result must like this:
1.aaa_1111_hello
2.aaa_2222_hello
3.aaa_1111_hello
4.aaa_4444_hello
5.aaa_zero_hello
6.aaa_5555_hello
7.aaa**_zero**_hello
8.aaa**_zero**_hello
...
100.aaa**_zero**_hello
Is it possible by iedit?
In github, the repository description has a wrong URL to the emacs wiki. It should be this instead:
Would be nice to make iedit search for '$foo' when invoking it insted of just using 'foo', but making only the 'foo' part be editable. Same goes for '@foo' and '%foo' and possibly '*foo'.
Sometimes I want to replace all the occurrences after point, rather than all the occurrences in a function or buffer.
Since C-u 0 means 'within the function', perhaps C-u 1 could be used?
Would it be possible to configure the buffer default mode ?
Currently it uses fundamental mode be nice if it could be changed to use Text mode or some other basic mode for editing.
or perhaps an iedit mode based of fundamental mode then you could make changes to iedit mode with out effecting other fundamental buffers.
The Iedit: 1/3
mode-line text, doesn't update correctly after calling iedit-restrict-function
.
C-x b
test
;; pre function comment
(defun test ()
;; first comment
;; second comment
;; third comment
)
;; post function comment
;; second comment
C-;
, the mode-line correctly shows: Iedit:3/5
S-M-h
The modeline now shows Iedit:0/3
The total number of occurrences 3
has updated correctly, but the current occurrence shows 0
.
The 0
should say 2
.
Pressing Tab
to move the cursor to the next occurrence, updates to the correct mode-line text Iedit:3/3
iedit-20180207.1019
Emacs 26.1
Windows 10 Version 1803
M-x iedit-mode
does highlight matches, and I am able to navigate between them. But when I edit any of the matches, only the match I've edited is changed, the rest are not.
iedit-mode
started to misbehave after I upgraded to Emacs 26.1.
Could somebody please confirm/refute this regression report?
THe current binding is counter-intuitive to me. It seems that "\M-p", which everywhere else in emacs is bound to an action that goes backward, is here used to expand the region forward, and "\M-n" used elsewhere for actions that go ahead, is here used to expand the region backward. Could these be flipped? If you like I can make a pull request.
Nice feature, by the way.
For some reason if I set the mark, invoke iedit-mode, then end
iedit-mode, the buffer no longer has a mark set. This means that using
popping the mark or exchanging it with point, as I often do for quick
navigational purposes, does not work. Most Emacs commands will leave
the last mark in place or set a new one pushing back on the mark ring.
Iedit is so excellent I continue to use it regularly in spite of
this annoyance. Thanks for it!
I just pulled after a few months. Some cool stuff there
::thumbsup::
Could you also add to MELPA stable, please? Because it only includes commits marked with release tags, I would expect it to become one of the more popular repositories over time.
It would be more clear if iedit-toggle-unmatched-lines-visible
would be just called iedit-toggle-fold
(iedit-toggle-fold-unmatched-lines
).
You fixed an issue for me recently, but the latest melpa version is 20120306. Would be nice to have the fixes in the repository.
@victorhge, just lettin gyou know. I'll submit PR for this later.
It would be nice to have something like sublime's CTRL-d
that incrementally selects next occurrences.
I know that is possible to expand the region below or on top, but as I've seen there's no way to select only the next occurrence and not just the next line (that could or could not have one or more than one occurrences)
M-x list-packages
does not have iedit
—is there some other repository I need to add? Or is this something that simply hasn't been paid attention to yet?
When editing c++ file (less than 3000 lines) with iedit-mode on, and there are no more than 10 matches, it lags too much. Emacs uses more than 80% of cpu when typing chars.
Not 100% reproduciable. But it happens too often.
When the iedit occur is working, the mode line shows the total number of the matching words.
Does there exists some settings to replace the info of mode line with "%d/%d", such as "1/20",
which 1 means the word is the first one, and 20 is the total matching words. Thanks.
Iedit-mode is very cool. I very love the way of this package work,
especial real-time visibility changing, very cool.
if we could extend this package to support following, more usable.
<foo>
....
</foo>
rename foo to bar
<bar>
...
</bar>
Hi !
In a c++ code (not tested with other language), iedit-mode fails replacing code if GTAGS, GPATH, GRTAGS are present (in my case they are located at the root of my c++ project). Some words are partially replaced (while well highlighted), others correctly replaced. When I removed these gtags files, iedit works very well.
Note: you have to restart emacs to get the issue after creating/removing gtags files.
Some info if needed:
sudo apt-get install global
I wonder is there any way to change the highlighted occurrences color? The current color accidentally coincides with my background color. So, it is hard for me to visualize all the occurrences.
With Emacs 24.5 and latest version of iedit, I experience weird behavior when the cursor is inside an occurrence and I delete the text from the cursor to the end of the line.
To reproduce:
emacs -Q -L /path/to/iedit/directory
M-: (require 'iedit)
foobar qux
foobar qux
M-x iedit-mode
-> "foobar" in both lines is highlightedC-k
(kill-line
)Expected result: buffer will look like this, with "foo" highlighted in both lines:
foo qux
foo qux
Actual result: iedit-mode is deactivated (nothing is highlighted), buffer looks like this:
foo
foobar qux
Original Issue reported by @jdwaterson here: syl20bnr/spacemacs#3193
Hello,
Thanks for this package. Just discovered it and am so sad about an issue preventing its use in my php buffers.
After selecting the string to be replaced, only part of it gets replaced as shown in video here : https://videobin.org/+isn/mw7.html
Not sure about what details I could give you. Please let me know how I could help you debugging this more if you can have a look at that.
(my configuration is here if that might give some contextual info : https://github.com/kermorgant/.emacs.d)
I recently found myself needing to change all occurrences of "pdf-view" to "pdf-tools" in a buffer. A perfect job for IEdit, I thought. I was a little surprised that when "pdf-view" occurred as part of a variable name rather than the whole symbol, IEdit ignored it.
This is good default behavior, but sometimes I want the other one; it would be useful to have something analogous to iedit-toggle-case-sensitive
.
A message of something like "restricted to current function, xx matches".
Ideally, flashing the affected region would be good as well, i.e. pulse the highlight face.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.