Visual Studio: Custom code highlighting based on regex

蓝咒 提交于 2019-12-04 22:46:16

问题


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.


回答1:


Edit: This is not an appropriate answer to the poster's question, but I cannot delete it because StackOverflow won't allow the accepted answer to be deleted.

This Visual Studio extension will do just what you want:

  • VSColorOutput - A Visual Studio extension to colorize your build and debug output

You can specify regular expressions for custom output window colorization.



来源:https://stackoverflow.com/questions/14255042/visual-studio-custom-code-highlighting-based-on-regex

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!