Visual Studio identical token highlighting

Visual StudioVisual Studio-2008Visual Studio-2005

Visual Studio Problem Overview


I coded a Mancala game in Java for a college class this past spring, and I used the [Eclipse][1] IDE to write it. One of the great (and fairly simple) visual aids in Eclipse is if you select a particular token, say a declared variable, then the IDE will automatically highlight all other references to that token on your screen. [Notepad++][2], my preferred Notepad replacement, also does this.

Another neat and similar feature in Eclipse was the vertical "error bar" to the right of your code (not sure what to call it). It display little red boxes for all of the syntax errors in your document, yellow boxes for warnings like "variable declared but not used", and if you select a word, boxes appear in the bar for each occurrence of the word in the document.

A screenshot of these features in action: ![screenshot][3]

After a half hour of searching, I've determined that Visual Studio cannot do this on its own, so my question is: does anyone know of any add-ins for 2005 or 2008 that can provide either one of the aforementioned features?

Being able to highlight the current line your cursor is on would be nice too. I believe the add-in ReSharper can do this, but I'd prefer to use a free add-in rather than purchase one.

[1]: https://www.eclipse.org "Eclipse" [2]: https://notepad-plus-plus.org/ [3]: https://i.stack.imgur.com/XZeTy.jpg

Visual Studio Solutions


Solution 1 - Visual Studio

There is a RockScroll alternative called MetalScroll which is essentially the same thing with a few tweaks and improvements.

Also there is a small and simple WordLight plug-in that only highlights the identical tokens.

Both are open source and support code folding which is nice.

Imho, the bar next to the scroll bar in Eclipse is a lot more elegant solution than the scroll bar replacement of RockScroll/MetalScroll. Unfortunately I couldn't find any VS plug-ins that do it the Eclipse way, so I just stick with WordLight.

Solution 2 - Visual Studio

Check following addins Productivity Power Tools- Displays error in scrollbar and

Highlight selected word

Solution 3 - Visual Studio

In a different question on SO (link), someone mentioned the VS 2005 / VS 2008 add-in "RockScroll". It seems to provide the "error bar" feature I was inquiring about in my question above.

RockScroll

EDIT: RockScroll also does the identical token highlighting that I was looking for! Great!

Solution 4 - Visual Studio

Old question but... Visual Studio 2010 has this feature built-in, at last.

Solution 5 - Visual Studio

The highlight functionality is conveniently implemented in VisualAssist. In my opinion, they are both must-have.

  1. Highlight identifier under editing caret: Options -> Advanced -> Refactoring -> Automatically highlight references to symbol under cursor

  2. Highlight search result - in all windows. Works for RegExps! Options -> Advanced -> Display -> Highlight find results

Solution 6 - Visual Studio

The automatic highlight is implemented in Visual Assist as the refactoring command "Find References". It highlights all occurences of a given variable or method, but that's not automatic (binded to a keyboard shortcut on my computer).

Here is an exmaple:

alt text

Solution 7 - Visual Studio

About RockScroll: It doesn't highlight the identifiers. It only highlights the same string in the source code! If there are similar identifier declared : ex. _test and test, and test is highlighted it will highlight the string "test" in variable _test too! And it will also highlight the same string in a method called "sometesting()". So it isn't exactly like eclipse and doesn't work for me.

Solution 8 - Visual Studio

DevExpress CodeRush does this when you press TAB when the cursor is in an identifier, you can then tab through all the highlighted instances. There's also a DXCore plugin (the foundation upon which CodeRush/Refactor Pro are built) that does current-line highlighting.

Solution 9 - Visual Studio

The "error bar" functionality is provided in JetBrains ReSharper. I'm not sure if it does highlighting of references to the currently selected identifier.

Solution 10 - Visual Studio

For selected word(s) highlight function only, there is also StickyHighlight.

StickyHighlight supports Visual Studio 2010 & 2012.

Solution 11 - Visual Studio

In VS 2017, this can be solved by installing the Match Margin plugin.

It appears to be part of the Productivity Power Tools (which might be worth looking at for other features), but surprisingly, installing PPT didn't solve the problem for me, I had to install Match Margin separately.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDarren SteinwegView Question on Stackoverflow
Solution 1 - Visual StudioAlex_PView Answer on Stackoverflow
Solution 2 - Visual StudiomeetjaydeepView Answer on Stackoverflow
Solution 3 - Visual StudioDarren SteinwegView Answer on Stackoverflow
Solution 4 - Visual StudioRoman StarkovView Answer on Stackoverflow
Solution 5 - Visual StudioCodeguardView Answer on Stackoverflow
Solution 6 - Visual StudioSteve GuryView Answer on Stackoverflow
Solution 7 - Visual StudioMichaView Answer on Stackoverflow
Solution 8 - Visual StudioDuncan SmartView Answer on Stackoverflow
Solution 9 - Visual StudioRoger LipscombeView Answer on Stackoverflow
Solution 10 - Visual StudiowipView Answer on Stackoverflow
Solution 11 - Visual StudioJan_VView Answer on Stackoverflow