Trevor Boyd Smith
Trevor Boyd Smith

Reputation: 19223

VS 2010: How do you undo after "Find and replace"?

On VS 2010, I do a "Find and replace"... I try to do a "undo" but... I can't... is there a way to "undo" after a "find and replace" or is this just a silly[1] limitation for VS 2010?

NOTE:

Obviously you can "reload the entire file"... but that takes way too much time and breaks up the productivity and workflow.

Foot note:

[1] ... by "silly" I mean... RIDICULOUS! What the heck?! How can VS 2010 not let you undo after doing a "find and replace"! Might as well call VS 2010 "Notepad 2010". (UPDATE: I just checked and notepad can actually do undo after a "find and replace"... soo ya.)

Upvotes: 11

Views: 23421

Answers (5)

Ruslang
Ruslang

Reputation: 1

For vscode:

  1. Go to git(lens) tab.
  2. Click on modified file.
  3. Do search with '[string]' you wish to revert on both areas(panels).
  4. Make right click on right (replaced) string.
  5. Click Revert Selected Ranges (CMD+K CMD+R).

Upvotes: 0

Network Noob
Network Noob

Reputation: 39

for me; I tracked changed files in source control (git tab) and discarded changes

image here

Upvotes: 0

zainnab
zainnab

Reputation: 1871

Assuming you are wanting to do a Replace All operation:

If you are using Quick Replace (CTRL + H) on “Current Project” or “Entire Solution” then it will open closed files automatically and mark them as dirty (put the asterisk in the file tab) when it changes them. An Undo will UNDO ALL CHNAGES so watch out.

If I you do a Replace in Files (CTRL + SHIFT + H) on “Current Project”, “Entire Solution”, or “Visual C++ Include Directories” then you need to select “Keep modified files open after Replace All”. If you do not select that option and click “Replace All” then you will get a dialog (regardless if the files where changes would be made are open or not) that gives you the chance to enable this option. If you do select it then it will open the files and mark them as dirty so you can Undo the changes. If you do not select the option then you cannot Undo the changes.

You can see more here: http://blogs.msdn.com/b/zainnab/archive/2010/11/25/undo-quick-replace-and-replace-in-files-vstipfind0020.aspx

Upvotes: 1

ewall
ewall

Reputation: 28100

Another tactic that sometimes works is to open up the Find/Replace panel again, and swap the values. (But obviously this doesn't always work because you might find more than you bargained for!)

Upvotes: 2

user438034
user438034

Reputation:

It can, if you tell it to keep the files open while replacing; Edit -> Undo.

Upvotes: 10

Related Questions