VisualStudio: Shortcut for when Renaming Variable

Viewed 123068

In Visual Studio, when you rename a variable name in its definition, there's a little underline in the last letter so if you hover that, you'll get the option "Rename OldVaribleName to NewVariableName" and so rename all entries in that procedure of that variable.

Is there a shortcut for that and not use the mouse?

13 Answers

These are known as Smart Tags.

You can use CTRL+.

Shift+Alt+F10 is another option.

In VS 2008 using C# you can just hit F2, not sure about other versions/languages, though. That also renames files in Windows Explorer if you're too lazy to right-click like I am.

I think the default is Ctrl + ..

If you like, I would suggest that you try ReSharper, it provides a lot of functionality for refactoring your code.

In ReSharper to rename a variable or function, simply use the shortcut CTRL+R, R.

(I know it may not be an answer to your question, but I think if you like using keyboard shortcuts that you will enjoy ReSharper).

For windows installation you need to double click the variable name (it will highlight all the instances) then press alt and double click the variables where you want to rename. Your will get all teh cursors and now you can delete the old name and give new name.

After the rename: CTRL+.

Before the rename: CTRL+r,r

VS 2017, Smart Tags enabled

Searched for this in 2019... What worked for me was to go to Options and add the shortcut on the Refactor.Rename command, like this

Related