Quicker replace var name

I saw in a video this one guy copy and paste a section of code, then he must have hit some combo keys and he changed a variable name and all the names below changed as well, with no sub-menus popping up. It was beautiful!

Right now, the way I do it is to select a section of code and CNTRL + D to copy it. Then CNTRL + H to replace, for which I have to type in the original var name and the new name. How can I achieve this like that one guy did or a similar faster way? Basically it should only affect the variables in the new copied section.

RENAME MULTIPLE IDENTICAL VARIABLES (BUT NOT NECESSARILY ALL IN FILE):
METHOD 1:
Select block of code, then CNTRL + H and type in replacement name.

METHOD 2:
A) Select entire var name & then hold CNTRL + ALT while double click on next var to be added as part of the group selection.
B) Place cursor at var name location want to start mod, then move mouse cursor over next var & press CNTRL + ALT to place new cursor & type new name.

METHOD 3:
Right click on variable name & select “Rename” or CNTRL + R twice on var name. Can also highlight name 1st then CNTRL + R once. In preview (no skip preview, unchecked), be sure to uncheck ALL other var’s that do not require change.
Posting the URL of the video might be a start.
Is it multi-caret editing (on visual studio)? You highlight the variable name, press Shift + Alt + . the number of occurrences afterwards you want to change, then start renaming it and it will rename the other occurrences as well.

You can also do CTRL + Alt and highlight everywhere you want the change to occur manually, then just start renaming it.


And not to be terrible, I like seeing activity in this forum, but chatGPT would have given you the answer lmao
Last edited on
In the spirit of cynicism, genius and I never would have thought of that! Maybe that is why we don't get as many posts in this forum ;)

Agreed, video would be awesome, but saw it months ago and in the wee hours of the night. Trust me, wish I had it now to playback in slow-mo. I think it was Cherno though. If I do ever find it, I will come back.

(CTRL+"") above, are the best clues to MSVS...using latest.

ChatGTP gave me part of my list above, and things like the older (CNTRL+D), (Alt+Shift+Up/Down)...etc. It also gave me (Alt+Shift+.), but sometimes I don't hit them in exact synchronicity.

In the video it was more magical and with less effort, there was no clicking of the next variable (cntrl+alt+click), and there didn't appear this sequential selection either. It was more click on top where want the variables changed and all other exactly named variables below become highlighted, then just change the name atop.

Thought I might ask here, since you masters seem like you would use this most often and know it like the back of your head. Based on your responses so far, I am thinking he must of re-assigned some key to (Alt+Shift+.) and just have hit it rapidly n times.

Appreciate the feedback.

Registered users can post here. Sign in or register to post.