Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Visual Studio replace

Ed__Jobe
Mentor

Visual Studio replace

Ed__Jobe
Mentor
Mentor

You know how in VS, when you put your cursor on a variable, it highlights all the variable occurrences? When I rename a variable, is there a shortcut to get VS to rename all the occurrences at once?

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Reply
Accepted solutions (1)
452 Views
4 Replies
Replies (4)

ActivistInvestor
Advisor
Advisor

Put the cursor on the variable identifier, and press F2

0 Likes

Ed__Jobe
Mentor
Mentor

...That doesn't seem to do anything for me. I tried putting the cursor in the middle of the var name, hit F2 and started typing, but it didn't do anything. It just put red squiggles under the other occurrences.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes

ActivistInvestor
Advisor
Advisor
Accepted solution

It could have something to do with changing your key bindings. 

 

On a default installation of Visual Studio, when I put the cursor on an identifier and press F2, I see this:

 

PressF2.png

 

You can also right-click and choose "Rename" from the context menu.

 

0 Likes

Ed__Jobe
Mentor
Mentor

@ActivistInvestor wrote:

You can also right-click and choose "Rename" from the context menu.

 


Oh, that one works. Nice! As for F2, I'm working from home right now on a laptop remoting to my work pc. Perhaps it's an rdp thing. I'll try F2 when I get back in the office.

 

edit: You gave me an idea. I went to options and found that it's command Refactor.Rename. My keyboard map (Default) is mapped to Ctrl+R. You're probably using VS pro. I'm using Community.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes