开发者

visual studio: is it possible to color custom tags in code?

Is it possible somehow to color specified code in specified color in any version of visual studio? For example, make background of

if( VERIFY( ... ) )

green and back开发者_JAVA技巧ground of

if( ! VERIFY( ... ) )

red? Maybe some addon exists or some version of visual studio has such functionality?


NO PLUGIN NEEDED

According to MSDN and this tutorial, you can set user-defined keywords for syntax highlighting in a usertype.dat file, which you should save in the same directory as Visual Studio's msdev.exe, or devenv.exe for VS.NET.

Now restart Visual Studio. Then in VS you can set the font properties for those keywords.

Edit: BTW, see the download here for a predefined usertype.dat with a lot of keywords ready to use.


You can use Resharper's "ToDo Items" to accomplish this.

  • Resharper -> Options
  • Create a pattern.
    Here you can specify the color, pattern, icon etc. This should already give you colorized code, the rest is optional, but makes it easier to find the patterns.
    (look at existing patterns for the syntax, or check the docs)
  • You can use filters to find the patterns, and combinations of patterns
    You could create a filter that contains both your patterns for instance.
  • use Resharper -> Tools -> ToDo-Items to search for the patterns


I don't know of an existing addin that does anything like that but I do know that Developer Express, the company that makes CodeRush, makes the addin engine freely available as a product called DxCore. This makes is much easier to create an addin that decorates the Visual Studio text editor. In Visual Studio 2010, a lot of the extremely difficult code that DxCore abstracts is no longer necessary as there is an official extensibility model for decorating the editor.

Here's a link to some DxCore plugin samples on Google Code.


No, but you may be interested in FxCop, it's more elaborate, but it should allow you the ability to detect the case you're talking about (via a custom rule, if it doesn't exist). It may be more work to set up, but it's worth it (especially if work in a team, and/or, have an existing CI system).


According to the VS Extensibility form Moderator, Ed Dore, it is not possible:

http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/93fc6d61-cfdb-432d-8541-d7dce498cef5/

Unfortunately, no. The code implementing the document tabbing was developed with native Win32 code, and currently doesn't have any VS SDK or automation hooks into it.

It is too bad as this would be beyond useful. (Keep track of different types of files and such.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜