Welcome to MSDN Blogs Sign in | Join | Help

Sara Ford's Weblog

My adventures embracing open source on CodePlex and at Microsoft

News

    • Did you know... All author proceeds go directly to sending Hurricane Katrina survivors to college.

      Microsoft Visual Studio Tips book

      Recent Entries

How to trick Visual Studio to not show line numbers for blank lines?

Going through my folder of my blog “contact me” emails, I came across this question. I like tricking Visual Studio into doing things, so I thought I’d share.

Is there a way to display only line number of coded lines, i.e. don’t number blank lines? Numbered blank lines makes showing code in powerpoint decks hard to follow.

Here’s the screenshot of what could go into your powerpoint deck.

line numbers only on real lines of code

To do this,

  1. Enable Word Wrap (Tools Options - Text Editor - All Languages - General)
  2. At the end of the first real line (like #28 above), start inserting white space until it goes off the screen. Note the Word Wrap glyph.
  3. Turn off the Word Wrap glyph (same place as in step 1) and Turn off “View White Space” (Edit - Advance – View White Space)

Here’s what the hack really looks like

what hack looks like using visible white space

Sorry, this isn’t the start of a new VS tip series. Just wanted to share some q&a that have come in through my blog.

Technorati Tags: ,
Posted: Thursday, August 27, 2009 2:30 PM by saraford

Comments

Josh Einstein said:

Wouldn't it be less hassle to just take screen shots of every page of code, open the resulting images in a hex editor and locate the bits that correspond to the line numbers you want to hide and turn them white? Plus if you trigger auto format all that hard work is gone.

# August 28, 2009 12:06 AM

Mike said:

Um, perhaps knowing something about these "powerpoint decks" would help, but this seems like a really lame way to get what is being asked for.

# August 28, 2009 10:37 AM

Luciano Evaristo Guerche (Gorše) said:

Sara,

In Visual Studio, I would run a "Find and Replace", passing "{\n} *\n" in the "Find what:" field and "\(120,1)" in the "Replace with:" field, assuring to "Find Options" > "Use" > "Regular Expression" be selected. If one has a wider monitor screen, it is just a matter of replacing 120 to a bigger number.

Just don't forget to WARN your readers, this is for presentation purposes ONLY and code changes SHALL never be committed/saved to disk :-)

# August 28, 2009 1:03 PM
New Comments to this post are disabled
Page view tracker