ChatGPT解决这个技术问题 Extra ChatGPT

Enable the display of line numbers in Visual Studio

Why doesn't Visual Studio have any way of showing line numbers in a source file? Is there any way to enable it, or a plugin for it? I know that the number of lines of code in a program doesn't matter, but sometimes it is nice to know how long a program is or the number of a particular line for reference.

Though I tried, I can't seem to find a way to enable line numbering and I find that surprising.

This is Visual Studio 2010 Ultimate. (If you have read my older questions, I've been using 2008 Express until now.)

@TomášZato at the time this was posted there was no such site!
What boggles my mind is that the line numbers are not shown by default.
@user1073075 Agreed. Stack traces point to line numbers, but what use is that if line numbers aren't in the IDE?! I wish MS would turn them on by default. Or at least, provide a shortcut, or right-click option on the left side of the editor. Having to dig through options dialogs is maddening.

J
James McNellis

Visual Studio has line numbering:

Tools -> Options -> Text Editor -> All Languages -> check the "Line numbers" checkbox.


You should check "Show All Settings" check box at the bottom of options window to see "line number" check box
Still hidden for SCSS files?!
If the "Line numbers" check box is checked and you still don't see the lines, uncheck the check box, click OK, the go back to Tools -> Options -> Text Editor -> All Languages, now check the "Line numbers" check box again and the lines should appear.
in VS 2017 my line numbers disappeared at some point, even though the tools/options check showed them selected. As @TH Todorov stated, I had to go back, uncheck, then recheck them and save for them to reappear.
In VS 2017 settings the square filled checkbox indicates partial application of a setting. It wasn't until I toggled the line numbers setting off and back on that it showed a normal checkmark and line numbers actually engaged for all languages.
0
0x6C38

As of Visual Studio 2015, you can find the option under:

Tools-> Options -> Text Editor -> All Languages-> General -> Line Numbers

https://i.stack.imgur.com/zWAO9.png

Or simply go to tools -> options and type on the search bar: "Numbers".


I don't have a search bar in tools -> options menu. How can I make it appear?
B
Brian Webster

Tools -> Options -> Show All Settings -> Text Editor -> All Languages -> Line Numbers


A
Abdessamad Doughri

In Visual Studio 2013 & 2015 :

https://i.stack.imgur.com/Acz41.png


d
davejal

It's not enabled by default but you can enable it by going to:

Click Tools Options Text Editor (expand) All Languages Line Numbers (Checkbox) Click Ok

settings


C
Community

In VS 2010:

Tools > Settings > Expert Settings

Then:

Tools > Options > Show all settings > Text editor > C# > General > Check Line Numbers (checkbox)


W
Wesam

https://i.stack.imgur.com/GfRxw.png


For my VS 2013, "Options..." was listed at the bottom of the "TOOLS" pull-down.
S
Sherif Hamdy

Visual studio 2015 enterprice

Tools -> Options -> Text Editor -> All Languages -> check Line Numbers

https://i.stack.imgur.com/Acz41.png


M
Martin Marconcini

Are you talking about seeing the line numbers or knowing the total number of lines in a project? Here is the 1st one


U
User001

Line numbers are not on by default. To turn on line numbers just go to Tools -> Options -> Text Editor -> All Languages -> General -> Display and check Line numbers:

http://blogs.msdn.com/blogfiles/zainnab/WindowsLiveWriter/TurnonLineNumbers_A5E7/image_thumb.png


C
Crux161

For me, line numbers wouldn't appear in the editor until I added the option under both the "all languages" pane, and the language I was working under (C# etc)... screen capture showing editor options


S
Seba Illingworth

Type 'line numbers' into the Quick Launch textbox (top right VS 2015), and it'll take you right where you need to be (tick Line Numbers checkbox).


u
user337826

For MS Visual Studio 2015 type "Text" in Quick Launch (Ctrl+Q) of top right corner. 1) quicklaunch

2) In the list select Text Editor->All Languages->General select_allLanguages

3) Now check on "Line Numbers" and click OK to get the line numbers.

Finally we get the line number in text editor.


You can also just type 'Line Numbers' in the quick launch to go directly to the right screen
G
Ganesh Kamath - 'Code Frenzy'

In Visual Studio 2010 Express, there is an option called "Show all Settings". Located at "Tools > Options", window.

https://i.stack.imgur.com/hYsec.png

If this option is not checked, the line number option will not be available. Make sure this option is checked like shown below. This will make lot of additional settings visible in the tree view to the left.

https://i.stack.imgur.com/a4LgB.png

Now this will make the option "Tools > Options > Text Editor > C# > General > Line Editor" available. Check the "Line Number" option to make line numbers visible on Visual Studio 2010 Express.

https://i.stack.imgur.com/l7cLp.png


S
Saurabh Verma

You should edit "settings.json". In that add, "editor.lineNumbers":"on", . You can check comments for various options you have.

In Visual Studio Code - 2017, you can also directly go to a given line number. There are following three ways to do that.

Directly use keyboard shortcut - Ctrl + G. Under menu Go, use Go to Line - Go > Go to Line Search for Go to Line in Command Pallete (Cmd + Shift + P).