Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a way to globally search text files in the project, and replace all occurences of a given text. It's very useful for navigating script name occurences or refactoring.
Should fix #16336.
Partially fixes #6217 (quite ambitious though)
Related to #2592 but doesn't fix its specific case.
When editing a text-based script, use
Ctrl+Shift+F
to open it (or use the menu), which is pretty standard for this action.(I had to change the default shortcut for "goto function" to
Ctrl+Alt+F
).A window will open:
If you had selected text, it will be copied in the search field.
In addition, the search field will be given focus. If you press enter just after that, it will trigger the search (so you can do it without touching the mouse).
If you press
Replace...
, the search will happen the same way, but you will be given the ability to enter which text to use for replacement.Search results are shown in the bottom dock, which opens automatically when a search begins.
If the search takes long, a progress bar can be seen, but you can still interact with the editor during the search.
Clicking a result will jump to the file and select the occurence (this should not conflict with the local file search).
Using
Replace all
will work on the files directly, and cannot be undone at the moment. Files that are open already will be reloaded using the same logic as external modifications do.Scripts embedded in scenes and resources are problematic for this tool because unless
tscn
andtres
files get included in the filter, it would require to preemptively load every single scene and resource of the project in case it has builtin scripts (which would slow down and complexify the logic due to varying data formats).This implementation is almost completely separate from the existing Search & Replace, because it works quite differently and on a larger scope.
Some features are not yet supported (such as looking only for opened files, using a thread, highlighting occurrences in the results...) but can be added later.
Known bug:
Sometimes, the top of the results panel cannot be resized, I have no idea why.