Visual Studio – why are line numbers off by default?
Seems totally backward to me that such an excellent IDE would hide line numbers by default. This seems like an obvious oversight, or poor default.
Which means I'm missing something – because in the VS dev team vs Me, I know who has more experience.
So what am I missing? Why wou开发者_JAVA百科ld I not need to see line numbers in code?
Line numbers are essential when pair programming. When two people are working together, it is very helpful to say something to the effect of "There is an issue on line 35"
The only time I'm interested in line numbers is when I've given a specific one (e.g. in a stack trace). At that point I want to go to that particular line (which I can do directly) but I don't need to see the surrounding line numbers.
I value the contents of my screen, and line numbers would just be wasting it for me.
I think the bigger question is to ask yourself why you would want to see line numbers. Why are they important to you? In what situations do you need to see all the line numbers for the current page, rather than just the current line (which is displayed in the status bar)?
EDIT: I agree with Michael's answer that for the specific example of pair programming, they're useful. Personally I don't happen to pair very often (I'm happy to do so, it's just rare) and so line numbers are not useful - and are even distracting - for the rest of the time.
Given that there has to be a default, then the most common preference would be the obvious one, and that would be 'off' by default.
Although I could easily do without them, personally I like line numbers because I tend to a) Orientate myself in a code file using them, b) Use them when talking to fellow programmers about code as the quickest way to get them to a specific line of code we're discussing and c) To give a whiff of code smell and remind me of how large a particular code file is getting that I am working on.
Its a user preference thing , there is no right or wrong way just create a customs settings file that has it turned on so that you don't have to remember to set it every time (Though i am sure this is only ever done once in a while since you rarely re install VS)
A far as I am concerned line numbers are just more screen clutter - I don't see any point in them.
What do you want them for? You're not programming in some 1980s version of BASIC are you?
What does it matter, as long as there is an option to show or hide them?
My preference is to turn them off - I think they are usually a waste of valuable screen space. You can see which line you're on in the status bar, and you can goto (ctrl+G) any line. But there are times when they can be useful.
Visual studio allow many ways of seeing your code. You can use the searches and drop downs for example. Line numbers may not mean anything to you if you have many named small functions for example. So though I like them its not really an issue is it?
For those interested in turning on the line numbers To display line numbers in code
On the Tools menu, select Options.
In the categories list on the left side of the Options window, expand the Text Editor node.
Expand the All Languages subnode and select General to set this option globally.
Note: Visual C# Express user must click Show All Settings to reveal the All Languages subfolder.
—or—
Choose the General options in the subfolder for the language in which you are programming.
In the Display section select Line numbers.
Line numbers can be of use for one and pain on the screen for another. And all they can help for: quick access to the exact line mentioned in exception stack log and easy way to implement changes introduced by code review.
Anyway, even if there are more usages, there are even more developers who do not use them. And that's a concern of VS developers: they give us means, but they don't switch them all on by default.
Obviously the only "definitive" answer would have to come from someone on the VS dev team. I always enable line numbers but after reading this post I'm starting to come around. In terms of "why off by default," I don't really see clutter as an issue. However, I do see a compelling argument for "forcing" yourself to not use line numbers. As Jon Skeet mentioned, the only time I really need a line number is from a stack trace. Specifically, from an external stack trace, since AFAIK all internal line references will also lead you right to the line if you click on them. For external references, I can see how I might save myself time by forcing myself to use "go to line" as opposed to hunting for it.
TL;DR? Turn off line numbers and you force yourself to use tools to find a specific line instead of hunting.
精彩评论