About the author

Steven Harmansteven harman :: makes sweet software with computers!

For recent posts and more about me, scroll to the bottom.

Subscribe

  • Subscribe to my feed. via RSS
  • Subscribe via email via email

News

Badges

  • Subtext Project
  • Support Subtext

Visual Studio Usability Tip: Highlight Current Line

This may seem like a completely obvious tip to some, and like a complete waste of time to others. But you know what? Its something that I've found extremely useful so I'm going to share it anyhow.

Hey, this is my blog and I can do what I want! :)

Update: I forgot to explain how to enable Highlight Current Line in the original post. I've now added instructions.

Highlight Current Line

This feature is not available in vanilla Visual Studio - its part of my favorite zero-friction productivity enhancer, ReSharper. I'm sure other productivity add-ins like CodeRush/Refactor! have something similar, but I don't know for sure. Maybe one of my friends can confirm... looking in your direction Dustin and/or Jay.

ReSharper - Highlight Current LineAnyhow, you can see it in action in the screen shot to the right.

Notice the slight variation in contrast between the standard background color and that of line #27. That's the highlighted current line.

The key for me not getting too much contrast between your standard background and the highlight color.

For a dark background you'll want a highlight that is just a few shades lighter, and for a light background you need a shade that is just a bit darker. The highlight should be obvious, but subtle. The point is not to distract your eye, but just to give it a visual cue.

OK... so?

So why exactly is this important, helpful, or even relevant? For two reasons:

  1. It makes finding your cursor extremely easy when navigating through your code base, which is really important when moving at the lightning fast speeds made possible by ReSharper and keyboard shortcut-fu.
  2. I like shiny things... and eye candy. And that's exactly what this is. :)

So how do I enable it?

First you need to turn the option on, and to do that you'll need ReSharper. So:

  1. Install ReSharper, FTW!
  2. In Visual Studio, open the ReSharper -> Options dialog.
  3. Open the Editor section.
  4. Check the "Highlight current line" option.

Next you need to set a custom highlight color, which you'll probably want to do because the default one is pretty ugly... and doesn't work well with dark themes. To do that:ReSharper Highlight Color Settings

  1. In Visual Studio, open the Tools -> Options dialog.
  2. Open the Environment -> Fonts and Colors section.
  3. In the Display items list, find the ReSharper Current Line and set your custom color.

Or the easy way...

If you're interested, you can grab the color scheme seen above (a variation on VibrantInk) from the CodeIncubator project's code repository. You'll find it in the IDE-Settings directory under VisualStudio.

Well, there you have it. Another possibly pointless usability/productivity tip from my IDE to yours. Enjoy!

kick it on DotNetKicks.com

What others are saying.

# Visual Studio Usability Tip: Highlight Current Line
Gravatar DotNetKicks.com
May 16, 2008
You've been kicked (a good thing) - Trackback from DotNetKicks.com
# re: Visual Studio Usability Tip: Highlight Current Line
Gravatar Travis Illig
May 16, 2008
The CodeRush plugin for this is available from Rory Becker (rorybecker.blogspot.com/.../...ntlineineditor.html)
# re: Visual Studio Usability Tip: Highlight Current Line
Gravatar Rory Becker
May 16, 2008
There was apparently a more comprehensive plugin (CR_LineHighlighter) written and the source is included in CR.

But the code I had to write (all 12 lines of it) to create my version shows just how easy it is to do almost anything using the DXCore :)
# re: Visual Studio Usability Tip: Highlight Current Line
Gravatar John S.
May 16, 2008
Good tip, except I wish the title had said "ReSharper Usability Tip". There are a lot of us that can't afford or don't like ReSharper for various reasons and I was expecting a tip using VS built-in settings.
# re: Visual Studio Usability Tip: Highlight Current Line
Gravatar Jay R. Wren
May 16, 2008
1. Install CodeRush
2. Press CTRL-W as many times as it takes for selection expand to expand to the current line.

My solutions was shorter than yours ;P
# re: Visual Studio Usability Tip: Highlight Current Line
Gravatar Steven Harman
May 16, 2008
@Travis and @Rory, thanks for confirming the Refactor! support.

@Jay and @Dustin, I'm disappointed in your lack of enthusiasm. Just kidding, I know you secretly use ReSharper and just put on the whole CodeRush/Refactor! show as a matter of public image. Your secret is safe with me... and anyone reading this comment. :)
# re: Visual Studio Usability Tip: Highlight Current Line
Gravatar Steven Harman
May 16, 2008
@Jay,

Let me start by saying, that's what she said.

And I'll finish by saying... your solution may have fewer steps, but it must be repeated every time. Mine is a one shot and done kinda thing. Meaning... I win! :)

Besides, everyone know that all great plans require at minimum three steps.

Step 1: Collect underpants
Step 2: ?
Step 3: Profit
# re: Visual Studio Usability Tip: Highlight Current Line
Gravatar Rory Becker
May 16, 2008
@John S.
My plugin should work with the DXCore (www.devexpress.com/Downloads/NET/IDETools/DXCore/) which is Free.

# re: Visual Studio Usability Tip: Highlight Current Line
Gravatar Jay R. Wren
May 16, 2008
Steven,

Yes, I see the difference now. that is DARNED COOL!
# re: Visual Studio Usability Tip: Highlight Current Line
Gravatar Phillip Jacobs
May 17, 2008
Yeah... I have Resharper and I really like the line highlighting but I turned off Resharper line highlighting in favor of the free addin by SlickEdit called SlickEdit Gadgets v2 for Visual Studio.
http://www.slickedit.com/content/view/441

It has several nice features such as line highlighting, a ruler, and a vertical line called an indentation guide. Oh and did I mention THAT IT'S FREE.

Also, I found that highlighting by Resharper was all messed up looking when I switched from a white theme to a dark theme and was almost unreadable.
# re: Visual Studio Usability Tip: Highlight Current Line
Gravatar Brian Canzanella
May 18, 2008
@Phillip Jacobs.

Visual Studio can handle vertical lines/indentation guides out of the box with some regkey tweaking...

[HKEY_CURRENT_USER]\Software\Microsoft\VisualStudio\9.0\Text Editor

Create a string value called "Guides"

The Value Data should be in this format:

RGB(x,y,z)n1,n2,n3,n4…

Where x,y,z is the hot color you want to pick and n are the placements of your guide lines. Here's mine… RGB(183,224,240)8,80,145

Restart Visual Studio and you should be ready to rock!
# re: Visual Studio Usability Tip: Highlight Current Line
Gravatar OJ
May 18, 2008
Nice feature.

I'm more of a VIM user myself, and hence use VIemu, the awesome VIM plugin for VS. Highlighting the current line is as simple as pressing 'V' in command mode :)

Cheers!
# Visual Studio Links #29
Gravatar Visual Studio Hacks
May 19, 2008
<p>My latest in a series of the weekly, or more often, summary of interesting links I come across related to Visual Studio. Via Jason Haley : Visual Studio Remote Debugger Service user account requirements . Jura Gorohovsky has posted ReSharper in Detail: Complete Statement Scenarios on the JetBrains .NET...</p>
Comments have been closed on this topic.