Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I count a specific variable in the code in Visual Studio?

HI

I understand that we can search specific word/Variable in VS2010 editor. For example, If I used a variable called (MyTest) and I want to count how many times I used this variable/word in the code of say (10000) lines. If possible, how can we do it in the current form or count the word in all form the project?

Thanks!

like image 305
Aharoun Baalan Avatar asked Dec 29 '22 05:12

Aharoun Baalan


2 Answers

Assuming you wont to search for "MyVariable" press Ctrl+H and the Find/Replace Dialog should open. Enter "MyVariable" into the "Find what" field and again into the "Replace with" field. Set the Scope to "Current Document" and press the "Replace all" button. A message will popup telling "xxx occurrence(s) replaced.", where xxx is the number you are looking for.

Press the "undo"-Button once, if you want to revert the document-state to unchanged.

like image 162
Rael Avatar answered May 28 '23 04:05

Rael


Can you not highlight the variable and press Shift+F12? This will tell you all of the matches found.

like image 40
Neil Knight Avatar answered May 28 '23 05:05

Neil Knight