68

I coded a Mancala game in Java for a college class this past spring, and I used the Eclipse 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++, 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

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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Darren Steinweg
  • 1,261
  • 1
  • 11
  • 15
  • 3
    Wish I could upvote this a million times. I hate how visual studio does pretty much everything. But this at least question/solution saves me a pretty major headache. – gnomed Aug 25 '11 at 16:23
  • More recent versions of visual studio have those features and a lot more. I think the highlighting goes back to MSVS 2010. Not sure about the scroll bar -- at least since 2012, I think. The scroll bar also has little red marks corresponding to lines that intelliSense thinks have errors (it's usually, but not always right). – riderBill Mar 31 '18 at 18:43
  • BTW, sometimes I find the MSVS highlighting to be distracting. Anyone know how to turn it off, e.g., when I'm just trying to select some text to copy or drag around? – riderBill Mar 31 '18 at 18:45

11 Answers11

32

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.

Alex_P
  • 1,886
  • 1
  • 19
  • 22
13

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

Highlight selected word

meetjaydeep
  • 1,752
  • 4
  • 25
  • 39
  • 4
    I've found that Highlight Selected Word and Productivity Power Tools don't work all that well together so my advice would be to use either one or the other. Also, the background colour of the highlight in Productivity Power Tools is found under Tools->Options->Productivity Power Tools->Enhanced Scroll Bar->Words Matching The Caret Location Color In The Editor. I found that kind of tricky to find, but that might just be me. – MikaelHalen Jan 31 '12 at 11:23
  • 1
    Thanks to both, Productivity Power Tools works great in VS2010 but the same word highlighting is disabled by default (color is set to transparent), to enable it you have to choose a color by hand like @MikaelHalen writes. – SemMike Apr 30 '12 at 00:23
11

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!

Community
  • 1
  • 1
Darren Steinweg
  • 1,261
  • 1
  • 11
  • 15
9

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

Roman Starkov
  • 59,298
  • 38
  • 251
  • 324
  • I hit some shortcut key that turned it off, do you know what it's called in VS? – Chris Stephens Feb 03 '12 at 22:26
  • 2
    This feature seems to be missing from Visual Studio 2010 Express, unfortunately. The Express edition is installed as a single-language setup, thus in a VC++ installation there is no C# entry in Options -> Text Editor where you can select the option "Highlight references to symbol under cursor". :-( – Christian Severin May 09 '12 at 09:30
  • 1
    @ChristianSeverin I believe you can install the C# Express edition along with the C++ Express edition, though not completely sure. – Roman Starkov May 09 '12 at 10:19
  • 1
    How do I get this for javascript files? – Donny V. Jun 11 '13 at 19:28
8

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

Codeguard
  • 7,787
  • 2
  • 38
  • 41
3

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.

Micha
  • 61
  • 1
  • 5
3

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

Neysor
  • 3,893
  • 11
  • 34
  • 66
Steve Gury
  • 15,158
  • 6
  • 38
  • 42
2

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.

Duncan Smart
  • 31,172
  • 10
  • 68
  • 70
2

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.

Michael Konečný
  • 1,696
  • 1
  • 16
  • 20
Jan_V
  • 4,244
  • 1
  • 40
  • 64
1

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

StickyHighlight supports Visual Studio 2010 & 2012.

Shannon Matthews
  • 9,649
  • 7
  • 44
  • 75
wip
  • 2,313
  • 5
  • 31
  • 47
1

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