Wednesday, December 5, 2018

Visual Studio extension to highlight all occurances of selected word

This is a useful visual studio extension. Just found its source code at

https://github.com/sunven/SelectionHighlight

I modified it to allow words beginning with @ or #. In MatchTagger.cs add this declaration:


private char[] allowedSpecialChars = new char[] { '_', '@', '#' };

Next, change foreach loop in private void OnSelectionChanged(object sender, object e) like so:


foreach (var c in text)


{
if (!char.IsLetterOrDigit(c) && !Array.Exists(allowedSpecialChars, ch => ch == c)) return;
}





That's it! It can now be built and added to our visual studio.

As a side note, also found out on stackoverflowhttps://stackoverflow.com/questions/9281662/how-to-debug-visual-studio-extensions that visual studio extensions can be debugged by add the following settings to first <PropertyGroup> in the extension's project file:


<StartAction>Program</StartAction>
<StartProgram>$(DevEnvDir)\devenv.exe</StartProgram>
<StartArguments>/rootsuffix Exp</StartArguments>

Reference: https://stackoverflow.com/questions/9281662/how-to-debug-visual-studio-extensions


No comments:

SSL Error - The connection for this site is not secure

 After cloning a git repo of dot net framework website and trying to run it all I could see was this error Turns out the fix was to simply e...