Undo Quick Replace and Replace in Files
Keyboard: CTRL + Z
Menu: Edit -> Undo
Command: Edit.Undo
Versions: 2008,2010
Published: 11/25/2010
Code: vstipFind0020
When using Find and Replace people often wonder under what conditions you can Undo the changes. Since doing a "Find Next" and "Replace" operation is very straightforward and easy to Undo, I'm going to focus on how to Undo the "Replace All" operations. Here is a summary of the conditions that allow Undo to happen:
Quick Replace (CTRL + H)
If I do a Quick Replace on "Current Project" or "Entire Solution":
Then do a "Replace All" By default it will open closed documents and mark them as dirty (put an asterisk in the file name tab) so you can Undo the changes:
When you Undo (CTRL + Z) here it will back out all the changes it made. In this case it will Undo all eleven changes:
For those wondering, this is what the entry looks like in the Undo stack:
Replace in Files (CTRL + SHIFT + H)
If I do a Replace in Files on "Current Project", "Entire Solution", or "Visual C++ Include Directories":
Notice there is an option to "Keep modified files open after Replace All". If I do not select that option and click "Replace All" then I will get this message regardless if the files where changes would be made are open or not:
Checking the "Replace All will open all files with changes for editing" will make it possible to Undo the changes made:
And here is the entry in the Undo Stack:
Finally
Hopefully this helps as you explore the inner workings of Visual Studio and how the various tools work.