Community
Participate
Working Groups
I wanted to use regular exrpessions to replace some string in many files. Suppose, I want to replace all (\w+)\.printStackTrace\s*\(\s*\) With my.package.Util.printStackTrace($1) I search for (\w+)\.printStackTrace\s*\(\s*\) Or maybe simply printStackTrace Steps: 1. search the string with the search tool 2. jump to the first match 3. enter the regular expression and the replace string into the find dialog 4. replace all 5. jump to the next match 6. (anoying) because the replace dialog automatically fills in the current selection, I have to select my regular expression again in the dialog 7. goto step 4. Proposal: have a setting to disable the automatic filling of the selection.
>I wanted to use regular expressions to replace some string in many files. This is not possible with the Find/Replace dialog except when you have the files open and activate the editor one after each other. Is step 5 correct? I cannot reproduce. Maybe you meant: jump to the next editor?
I do the "global replace" in 2 steps: 1. I use the normal string search dialog to find all matches across files. 2. I use the "Show Next Match" button in the search view to navigate to the candidate files. In those files I use the Find/Replace dialog. To see the effect, you have to: 1. open a Find dialog (and set the search string to something) 2. do a file search 3. hit the "Show Next Match" 4. set the focus into the editor (e.g. by clicking the title of the editor) --> the "Find" field in the find dialog changes to the selection of the match Maybe there is a better way to do "global replace".....
>Maybe there is a better way to do "global replace"..... Yes there is but it does currently not allow you to use regex in replace string, only in search string: 1. open the Search dialog and flip to the File search page 2. do the search 3. in the Search view select the matches you want to replace and from the context menu select "Replace..." or "Replace Selected..." There are feature requests to improve this (i.e. make it more prominent and allow to replace all matches without asking). I changed the summary of this bug since it is not regex specific. We do the selection on purposes: this allows you to enter a replace string and immediately replace the selection. This is the 80% behavior when you open the Find/Replace dialog. Maybe we have to come up with a better strategy when the dialog is already open.
request to not autmatically fill the find expression is a dup of bug 6202. *** This bug has been marked as a duplicate of 6202 ***
I absolutely agree that populating the find field is "the 80% behavior *****WHEN YOU OPEN****** the Find/Replace dialog." However, WHEN THE DIALOG IS ALREADY OPEN, I would argue that magically RE- populating the find field is the 0% case. I actually disagree very strongly that anyone ever uses that 'feature' of the Find/Replace dialog. Correct me if I am wrong, with a concrete, useful, not contrived example, and I can probably be convinced that it is the 1% case. Because the find field can be repopulated with the selection at any time by simply typing ^F again, the automagic repopulation when switching editors is counter-intuitive and counter- productive.