Edit

Share via


Display line numbers in the editor

This article describes how to show or hide line numbers in your code.

Note

If you enable line numbering, the line numbers you see aren't added to your code. The numbers are displayed in the view for reference only.

  1. Open the Tools > Options pane, and expand the All Settings > Languages section.

  2. Expand the language section you're using (such as C# or Visual Basic), and then expand the General section.

  3. Select the Line numbers checkbox to show line numbers, or clear the checkbox to hide line numbers.

    Screenshot that shows how to enable line numbering for a specific language.

You can also configure line numbering for all supported programming languages. There are several methods to access the default global setting:

  • In the Tools > Options pane, expand the All Settings > Languages > Defaults > General section. The Line numbers setting on this page is the global option for all supported languages.

  • Use the Visual Studio Search box. Select Ctrl+Q to open the Search box, and enter line numbers. In the results list, double-click the Line numbers (languages.defaults.general.lineNumbers) entry.

    Screenshot that shows how to use the Search feature to configure the default line numbers setting.

    The Options pane opens to the section that contains the global Line numbers option.

  • In the Options pane, enter line numbers in the Search box above the navigation tree. The tree refreshes to show the section that contains the global option. Select the section to go to the Options page that contains the global Line numbers option.

  1. On the Visual Studio menu bar, select Tools > Options.

  2. In the Options dialog, expand the Text Editor section.

  3. Expand the language section you're using (such as C# or Visual Basic), and then expand the General section.

  4. Select the Line numbers checkbox to show line numbers, or clear the checkbox to hide line numbers.

    Screenshot of the Options dialog that you can use to show or hide line numbers in the Visual Studio editor.

  5. Select OK.

You can also configure line numbering for all supported programming languages. There are several methods to access the default global setting:

  • In the Tools > Options dialog, expand the Text Editor > All Languages > General section. The Line numbers setting on this page is the global option for all supported languages.

  • Use the Visual Studio Search box. Select Ctrl+Q to open the Search box, and enter line numbers. In the results list, double-click the Turn line numbers on or off entry.

    Screenshot that shows how to use the Search feature to configure line numbers for all programming languages.

    The Options pane opens to the section that contains the global Line numbers option.

  • In the Options dialog, enter line numbers in the Search box above the navigation tree. The tree refreshes to show the section that contains the global option. Select the section to go to the Options page that contains the global Line numbers option.