Microsoft revamps Visual Studio search – but misses a long-standing request DEVCLASS
Microsoft has previewed a new search feature for Visual Studio 2022 – but still no way to search code while excluding comments. Developers have been asking for such a feature since 2018.
The revamped tool is described by product manager Denizhan Yigitbas as “an all-new, all-in-one search experience.” Code research is important for developers because it helps them navigate, understand, and refactor code. Microsoft must also believe (as with Office apps) that developers need help finding their way around the IDE itself, so feature finding is built into the product as well.
All-in-one search isn’t as new as it sounds. The production version of Visual Studio 2022 already has a search icon in its top menu bar, with options for “All”, “Code” and “Features”. The preview version, however, opens in a separate floating window, with an option to keep it open as an always-visible tool. It also supports filtering searches to include only files, types, or members. This type of filtered search was also available before, but perhaps not as widely known as it deserves, as it can be more efficient than plain text search.
A possible point of confusion is that Visual Studio has search options in its Edit menu as well as the search icon in the top bar, including the venerable search in files, quick find, and quick replace.
Some developers are unsure if Microsoft is in the right place. A comment on the Yigitbas post asks the company to “please stop wasting time with new searches and provide an option to search only the code” – the point being that it still doesn’t exist easy way to exclude text in comments. A 2018 feature request identified this need, which has been “under review” since July 2019.
This IDE is called “Visual Studio” but command line searches can be a good alternative to using graphical tools. The grep command line, too – most familiar on Unix-like operating systems – is fast and efficient. Developer Ben Hanson has created a free utility, gram_grep, which combines grep with user-defined grammars for refined searches, at the cost of some complexity, but allowing features such as ignoring results in comments . Some developers would prefer a simple checkbox allowing them to exclude comments from searches without having to use third-party tools.