Sometimes I need to change a variable name in the code from foo to bar. I do it using query-replace-regexp. Then I would do some other stuff and I might regret my decision and want to change it back from bar to foo. If I do query-replace-regexp, it will show by default the last replacement performed (default foo -> bar). My question is, is there a quick way to tell Emacs I want the reverse order of the default? Otherwise one would need to type the whole thing again.
Edit: The default replacement is the last replacement (default foo -> bar). What I want now is the opposite: bar to foo. Basically, I want to undo the replacement. Not always can I use the undo feature since I may have a very long history after many other edits.
query-replace-regexpthan it does for plain oldquery-replaceas your query and replace strings can have capture groups and backrefs in the prior that wouldn't make sense to reverse.(default foo -> bar). What I want now is the opposite:bartofoo. Basically, I want to undo the replacement. Not always can I use the undo feature since I may have a very long history after many other edits.