Search code examples
phpstorm

Execute search/replace in PhpStorm as action


I'm looking for a solution to:

  1. store favorite "Find Occurrences of ..." and
  2. execute them without any more questions by the UI in one stroke

I know the option ALT + 3 -> STRG + E to open the last Find Usages, but that are only "Find" and not "Replace in Path" actions

Maybe I need to develop a plugin - that could look like this:

DO REPLACEMENTS:
----------------------------------
[X] foo -> bar
[ ] bar -> foo
[X] ): boolean -> ): bool
----------------------------------
[add] [execute] [execute & review]
----------------------------------

but any other ideas are welcome!

Important is to use PhpStorm`s file scopes! Because I would like to use my own custom scope.


Solution

  • You can use "Structural Search Inspection". It's base on the "Structural Search and Replace" engine which is pretty powerful. Once configured you can run the inspection using the "Run Inspection by Name..." action with a custom scope. It has a quick fix which can be used to replace occurrences.