I am working on some game in VS10, and I want to change the name of some variable, because I want to expand the game, however there is so much references to it, that I don't know from where to start. Is there any hotkey in VS10 that will do this in a moment for me? I know there is NetBeans hotkey CTRL+H, but this doesn't work for VS10.
Place the cursor inside a variable you want to rename and press Ctrl + R . Then type other name and editor will change all occurrences of that variable. Save this answer.
If you select a variable/method and hit F2, you can edit the name and it will change every instance of that variable's name throughout the entire current working project.
Press F2 and then type the new desired name and press Enter. All usages of the symbol will be renamed, across files.
Select the variable you with to change, right click, and select Refactor->Rename. This will highlight all instances of the variable. Changing the variable name is automatically propagated to all of the instances. Thanks.
First, any variable should always be declared and used in the smallest of scope.
In VS2010, whenever you rename a variable, it will prompt you whether you want all references to this variable is to be so renamed. A little red bar will appear underneath the name where you changed it. Move your mouse to that bar and an icon will appear with "Options to update references to the renamed object". You can choose between renaming all right away or with preview.
(The ability to rename all references to the renamed variable disappears when you go and rename another different variable. Perhaps there is a way to go back to an older rename but I have not found it.)
I tried renaming a public property of a class. The automatic renaming works too for references to that public property, at least when both are within the same code file.
As Retired Ninja said in his comment, you pretty much need add-ons for Visual Studio (like Visual Assist X).
Installing Visual Assist will give you a menu like this:
... where the "Find References" button searches for all references to that variable/function/namespace/etc and replaces it (not just a plain text search).
Other alternative is to open the "Find and Replace" window (press Ctrl+F), and click "Quick Replace". From there you can do a plain text search and replace (there's also wildcard and regex support (under "Find Options->Use:), if that helps).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With