Compartir a través de


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: VS2005Tips,VS2008Tips

Comments

  • Anonymous
    August 27, 2009
    The comment has been removed
  • Anonymous
    August 28, 2009
    The comment has been removed
  • Anonymous
    August 28, 2009
    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 :-)