How to: Display Line Numbers in the Editor

Note

This article applies to Visual Studio 2015. If you're looking for Visual Studio 2017 documentation, use the version selector at the top left. We recommend upgrading to Visual Studio 2017. Download it here.

You can display or hide line numbering in your code.

Note

Depending on your active settings, the dialog boxes and menu commands that appear might differ from the ones that are described here. To change your settings, open Tools / Import and Export Settings. For more information, see Customizing Development Settings in Visual Studio.

Display Line Numbers in Code

Line numbers aren't added to your code; they're just for reference. If you want line numbers to print, in the Print dialog box, select the Include line numbers check box.

To display line numbers in code

  1. On the menu bar, choose Tools, Options. Expand the Text Editor node, and then select either the node for the language you are using, or All Languages to turn on line numbers in all languages. Or you can type line number in the Quick Launch box.

  2. Options for displaying line numbers in the editor

Note

Depending on your language or settings, you may have to select the Show All Settings check box in the Options dialog box to reveal the All Languages sub-node.

See Also

Customizing the Editor
Text Editor Options Dialog Box
Writing Code