views:

447

answers:

3

Hi,

I use GVim and Visual Studio for coding. One of the most missing features in VS compared to GVim is the possibility to highlight several words in different colors simultaneously. See this screenshot of a GVim session for an example (wResult and fBufferLocked are marked)

In GVim I use this feature very often to get a quick overview where which variable is used.

I haven't found a plug-in which provides this feature for VS. I know solutions which can highlight one(!) keyword, but not several and in different colors. So I plan to write a plug-in for VS 2008 which implements this feature (unless someone now gives a link to an off-the-shelf plug-in which does what I'm missing so much ;-))

Well, the problem is that I'm not experienced in writing plug-ins for VS 2008 (or any other VS). And before starting to learn what the plug-in architecture of VS is I would like to get some feedback from you whether such a plug-in is possible at all and what effort it is to implement it.

The idea is the following:

If the user presses a specific shortcut key in VS's code editor the word under the cursor is added to VS's syntax highlighting. Say this is word 1 with background color 1. All keywords "word 1" are highlighted now.

If the user moves the cursor over another word and presses the shortcut key this word will also be added to the syntax highlighting, but with a different background color. Say this is word 2 with background color 2.

If the cursor is over an already highlighted word and the user presses the shortcut key then the word is removed from the syntax highlighting.

So basically the plug-in should add keywords to the current syntax highlighting and remove them on demand.

My questions:

  1. Is the approach to do this via syntax highlighting and plug-in a correct one or are there (better, simpler) alternatives?

  2. Does this approach work at all? Or, to put it differently:

    2.1. Can an existing syntax highlighting (e.g. C++) be expanded while VS is running?

    2.2. If a keyword is added/removed to/from the syntax highlighting on runtime, when does VS update the editor's view? Automatically when changing the highlighting, must and can a plug-in trigger an update of the editor's view or must VS be restarted (the last one would be the knock out for this idea)?

  3. Is there an open-source VS 2008 plug-in which does something with syntax highlighting, marking code or anything similar which I could use as a starting point to learn? A good starting point in MSDN seems to be this and rightnow while typing this I have found a plug-in which at least deals with syntax highlighting.

Thank you in advance for your comments...

Greetings
Habi

A: 

This doesn't answer your question expressly, but if you want gvim features in visual studio you can use ViEmu. They offer a 30 day free trial, but a license will set you back $99.

Matthew Vines
As far as I know ViEmu does not support Vim plugins and this feature is implemented as a plugin.
Habi
A: 

Hello,

I would say if you don't mind scoping problems then the colourising should easy to do for you our language (I'm the developer of link 3), but I'm not sure if you can add extra colouring to an existing language. But I'd assume that you can.

Simeon Pilgrim
+2  A: 

I'd suggest you take a look at DXCore from DevExpress. It's a free API that CodeRush/Refactor! is built on. It will make doing something like this much simpler. There are a bunch of plug-ins available at link text that can help give you some examples/starting code.

Paul Mrozowski