Automatic return line allocation

Eclipse (at least when using Java) has the function of automatically highlighting all the lines in a method when the method returns, when I put the cursor in the return type in the method definition.
Is there such an option for C # in Visual Studio + ReSharper 5.1.3?

Code example

string Do() { if(/**/) return ""; // here if(/**/) return "1"; // here if(/**/) return "2"; // here throw new Exception(""); // here } 

When I put the cursor in the word string in the first line of this example, the lines marked with // here should be highlighted.

+6
source share
1 answer

It looks like the VS2010 extension, called Linguist , will be close to what you want. He can make individual selections for any regular expression. It seems that he cannot change it based on your cursor location.

More information about the extension can be viewed on the github page .

No GUI for settings. Instead, there are %LOCALAPPDATA%\Linguist settings files that you configure.

Since I already have my syntax highlighting the way I would like to be with Resharper, I removed all the formatting from the Styles.field file in the standard subdirectory. If you do this, you need to leave all the names, so it will look like this:

Styles.field

 # If new elements are added (or old ones removed) then Definitons.cs # and Languages.Init have to be updated. Name: attribute Name: command Name: comment <<< keep all the names in this file, just remove formatting >>> 

You will need to configure one of the named styles to highlight. I did:

 Name: emphasis BackColor: Red 

And then I created a file called custom.lang (but you can name yours with the .lang extension) in the custom subdirectory. and this is what I did to highlight the return statements:

custom.lang

 Language: csharp Globs: *.cs Emphasis: \breturn\b Emphasis: \bthrow\b 

It made me work. A bit complicated, but it's free. Another way to do this might be to clear the standard\C#.lang so that you can leave other files in place.

And finally, another option, since it is on github, you can add a new style definition for the selected text so that we do not destroy the rest of the formatting. Nice to have options :)

+2
source

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


All Articles