views:

185

answers:

1

In case my initial approach is wrong, here's what I'm trying to accomplish. I want to be able to recognize snippets of text in my code editor (I'm using C#, but that shouldn't matter) and change the way they are formatted. Perhaps use different colors or fonts, etc. I started off thinking this would be as easy as popping a regular expression into a config file somewhere and setting some defaults... not so much.

I've so far identified two potential ways to do this, the first is by creating a new Language Service for Visual Studio. I don't think this makes sense because I'm really only augmenting the default C# lex & parse.

The second is by Creating Custom Text Markers. This seems better, because if I'm reading it correctly this will allow me to create my own rules for recognizing sections of text (regex, etc) in the IDE and add Text Markers based on that. Those will then be exposed in the Options -> Environment -> Fonts and Colors area in Visual Studio Options (similar to ReSharper Overrides, ReSharper DeadCode, etc.).

Assuming the Custom Text Markers route is the way to go, and I'm open to other ideas, I need to implement the IVsPackageDefinedTextMarkerType interface and implement the GetTextMarkerType method. Sounds pretty straight forward...

I then need to "proffer [my] marker type as a service", this is where I get a little lost. There is an example of creating a custom service in the Visual Studio SDK, but I can't figure out how to tie the two together. I've still got a lot of research to do on this topic, so I may answer my own question, but it'd be nice if someone could save me some time!

+1  A: 

I believe that the following projects use custom text markers. They might give you some ideas:

Kramii
I'll take a look at that, thanks for the tip
MKing