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

Hi

I understand that we can search for a specific word / Variable in the 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 lines of code (10000). If possible, how can we do this in the current form or read the word in all forms of the project?

Thank!

+3
source share
4 answers

Assuming you donโ€™t want to find โ€œMyVariableโ€, press Ctrl+ Hand the Find / Replace dialog box will open. Enter "MyVariable" in the "Find what" field and again in the "Replace with" field. Set the scope of the "Current Document" and click the "Replace All" button. A message appears informing you to replace "xxx occurrences." "Where xxx is the number you are looking for.

Click the โ€œcancelโ€ button once if you want to return the document state to unchanged.

+4
source

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

+3
source

"MyTest", .

  • (CTRL F) . . , , ..
  • Bookmark all
  • Then open the Bookmarks window ( View-Bookmark window) to view a list of all bookmarks. It does not show the total number, but you can easily calculate them manually here.
+1
source
  • Ctrl + Shift + Fto open the Search Files dialog
  • Enter a name and a search field (document, project, solution, etc.)
  • Find all
  • Scroll to the bottom of the resulting Find Resultsand you will seeMatching lines: xxx

enter image description here

+1
source

Source: https://habr.com/ru/post/1774069/


All Articles