Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio: Custom code highlighting based on regex [closed]

As my application supports some paranoid debug level (every data assignment, every step in the code is written to a log destination), my code is littered with logging calls in some methods, e.g.

logger.Log(LogLevel.Debug, 0, "Initializing i18n...");
Lang.Language = SystemInfo.Language;
Logger.Log(LogLevel.Debug, 0, "Default system language: " + Lang.Language);
string[] languageFiles = Directory.GetFiles(ClientEnvironment.LanguagePath);
Logger.Log(LogLevel.Debug, 0, "Initializing local language files...");

As you can see, there are only two "real" code lines. This makes the code somewhat hard to read. I wonder whether I can specify some custom code formatting rule within Visual Studio to let the logging lines appear in a soft gray text color, instead of the default text color. This would lead to an implicit highlighting of the "real" code lines, resulting in a more readable code.

I need something like:

If statement starts with "logger.Log", set foreground color to gray.

Do you know any plugins which could archieve such a behaviour? Thank you in advance.

like image 557
mbue Avatar asked Jan 10 '13 09:01

mbue


1 Answers

altrue.CustomColoring extension allows to set custom foreground color based on simple regular expressions. Restart Vs Code after installing it, it won't work correctly without restart.

enter image description here

https://marketplace.visualstudio.com/items?itemName=altrue.CustomColoring

like image 92
Sergei Avatar answered Oct 23 '22 01:10

Sergei