I'm trying to do a find and replace over many files within an Eclipse project, but I can't seem to find a way to do it. Googling showed me that there are plug-ins that can accomplish this, but is there any built-in functionality in Eclipse? (It seems to be a pretty basic task; it's surprising me that I can't find a way to do it.)
Asked
Active
Viewed 9.5k times
2 Answers
279
Search->File
menu (also accessible using Ctrl+H
, then navigate to File
tab), enter the text to search for, hit the Replace...
button which will give you another dialog where you can replace text.
-
28strg/ctrl + h is the shortcut ;) – j7nn7k Oct 04 '11 at 20:51
-
2Does anyone know of a way to make searching across the current project the default when opening the search dialog? I constantly find myself opening the dialog, only to have to close it again, then go right-click on the project and do search from there (then make sure "selected resource" is selected in the dialog box). – Travitron Apr 27 '12 at 11:22
-
1@LihO it works fine. In File Search, enter the text in `containing text`. For `File name patterns` put "*", then hit `replace` and type in the text you want to replace with – TAAPSogeking Nov 09 '14 at 16:52
-
got a Multiple annotations found at this line: - The content of element type "property" must match "null". - Attribute "type" must be declared for element type – Siddharth Aug 05 '15 at 16:47
-
Take care when you are working with Subversion system which puts the repository in the same directory. **Do not forget to exclude** the repository from the replace process! – Peter VARGA Nov 18 '15 at 16:50
-
This can also be used with preserving the case of the replaced text (as described for the single file Search/Replace Ctrl+F in https://stackoverflow.com/a/61120051/14157403): Enable “Regular expression” in the search dialog as well as in the replace dialog and precede the replace string with “\C”. – chrisemb May 31 '22 at 09:39
-
After your replace you may see errors due to package import missing, to resolve that, select your project, go to source -> organize import, should solve it. – Musa Jul 05 '22 at 20:40