Did you know… How to print line numbers in VS?

To print line numbers in Visual Studio .NET 2003, go to File – Page Setup, and check “Line numbers” in the lower-left hand corner.  The line numbers will appear in the file, regardless whether you have line numbers displayed in the editor.

In Visual Studio 2005, we’ve moved this option to the Print dialog.

I should probably mention how to show line numbers in the editor.  Go to Tools – Options – Text Editor – General page and check “line numbers”.

Happy Editing!

Comments (4)

  1. This is a great feature, but way broken in VS.Net 2003 in regards to code outlining.

    Currently, if a section of code is closed and then printed, the line numbers ignore the number of lines that are closed. There also is no indication that the section of code is closed!

    Bummer, and effectively ruins printing w/ outlining.

  2. saraford says:

    Yeah, I agree with you about the printing story in Visual Studio .NET 2003. For what it is worth, you can identify a line that is hiding a selection on the printout by the "…" at the end. At least it is something to go by.

    Visual Studio 2005 has an improved printing story. If you’re printing a doc with hidden regions, the entire contents will be printed, as if you had disabled outlining. This way, the numbers are in sync. There’s also an option not to print hidden regions at all.



  3. saraford says:

    Let me finish explaining my last statement, "There’s also an option not to print hidden regions at all." I typed this one a little too fast…

    Checking the option to hide hidden regions on the print dialog will provide the Visual Studio .NET 2003 behavior (with hidden regions indicated by a "…" at the end of the line). However, the line numbers are correct, that is if there’s a hidden region of 3 lines on line 4, you’ll see the following line numbers: 1, 2, 3, 4, 7, 8, etc.

  4. Jerry Frost says:

    I found the Display Line Numbers check box in Tools – Options – Text Editor – ALL LANGUAGES – General page instead. I had to look under All Languages to find it.

Skip to main content