Tips and Tricks

Filter using logical “or”

Many of the dialogs and drop-downs of Visual Assist allow efficient lookups via filtering. For example, filtering within Open File in Solution—a dialog with all files in a solution—lets one find a file quickly if only portions of a name are known. This means one can find veryLongFilenameInProjectTomato.cpp if he knows only “long” and “toma”.

Filtering takes many shapes. Aside from substrings, one can filter using simple expressions. Our expression syntax isn’t full regex but it is tailored to the content being searched.

In this blog post, I introduce searching using logical “or”.

Filtering using logical “or” is often applicable when searching VA Hashtags, where tags are created on-the-fly and often without standards. For example, developers might annotate code with VA Hashtags of the format “todo” followed by the name of the teammate who needs to review or fix the code, but names are entered as first names, last names, or misspelled variants thereof.

For tasks related to developer John Smith, we might find VA Hashtags in either of the following forms.

// #todoJohnSmith
// #todoJSmith

Filtering for “smith” in the VA Hashtags tool window easily finds both.

logicalOrSmithDialog

But a teammate might annotate code with only John’s first name.

// #todoJohn

In this case, filtering for “smith” won’t find the new hashtag. We need to search for “smith or john”, and we use a comma in our expression to do that.

logicalOrSmithJohnDialog

Then, our code might also include unrelated hashtags for John, e.g., a comment directed only at him.

// #John, I fixed this for you.

The previous filtering for “smith or john” will include the unwanted entry.

logicalOrSmithJohnDialog2

To omit the unwanted entry, we need to search for “todo and smith” or “todo and John”. We do that with multiple substrings and a comma.

logicalOrSmithJohnDialog3

This final expression using logical “or” gives us exactly what we want.

You can use expressions in all dialogs and drop-downs that support filtering, including the several that support logical “or”:

If you want to know more about expressions, study one of the features that supports logical “or”, then experiment in all the dialogs and drop-downs you encounter.

Logical “or” requires Visual Assist build 2062 or newer.

Leave a Reply

%d