Reputation: 6126
I have a log statement that looks like this:
Log.debug("text={}", "something");
That I want to replace with:
Log.debug("something");
Instead of doing a ctrl+F
and going one by one to replace this is there a way to replace everything at once with any combination of intelliJ macros + scripting + regex?
Upvotes: 2
Views: 534
Reputation: 482
There are two ways of doing this:
1.) You could use the ctrl + f
way, but search for the entire statement
Log.debug("text={}", "something");
and then go to the replace textbox and type the desired statement
Log.debug("something");
and then just hit the Replace All
option.
2.) The other way is with a regex, but you will invest more time in creating a regex that match what you need and then replace it with the statement you want. I recommend you using the first way since it would minimize the time invested.
EDIT.
There are 2 more ways:
The 3rd way, you could use the Add Selection for Next Occurrence
short cut (hit ALT+CTRL+S
and search for that option and see its shortcut or assign one if there isn't one) and then just highlight the statement you want and hit that shortcut until you find them all and then type the desired statement.
The 4th way, highlight the statement and hit the Rename...
shortcut (find the shortcut the same way explained on the 3rd way) and it will refactor all the matches.
Careful with the last one because intellij sometimes match all those occurrencies in all the project/projects you have open at that time in the same project structure; Of course, you could check and uncheck the ones you want to change and those who you don't want to.
Let me know if any of these possible solutions worked for you =).
Upvotes: 2