I feel weird when I'm editing code in an IDE that does not have line numbers in the text editor.

The questions I have are:

  1. Are line numbers visually excessive, particularly when a find by line function exists in your IDE of choice?
  2. What are the uses of showing line numbers?
  • 35
    2: Feel totally macho over number of lines of code written. Sep 7, 2011 at 17:59
  • 4
    @AdamCrossland: funny you should mention that, I typically see it as exactly the opposite and the more lines of code I write, the more time I end up spending looking over it to make sure I didn't do anything twice and that I'm meeting spec. Sep 7, 2011 at 18:08
  • 4
    yeah that's all true for me too, but sometimes you just have to strap on your motorcycle helmet and go for the macho. Sep 7, 2011 at 18:12
  • 3
    I find it faster to scroll with an eye on the line numbers than use the goto line function of my editor (that might be because I first have to find it each time), especially when I'm already close Sep 7, 2011 at 18:44
  • 7
    @Adam : Feel totally Macho at how few lines of codes I have written to make it work.
    – Newtopian
    Sep 8, 2011 at 6:30

11 Answers 11


Anything that aids communication is a plus.

  1. It doesn't take up much space so no, it's not excessive if you or any of your colleagues find it useful to discuss the code.

  2. Even if you don't do pair programming, it is useful for "over the shoulder" code reviews if you don't use tools like Code Collaborator (we don't right now).

Also if you have team members in other sites (we do), it's useful for discussing code via IM or on the phone.

How can you tell them tell them to go to line 1842 if you can't see the line?

For me it's an invaluable simple little tool. Even some of our pdf specs have numbered lines, and it's amazing how much easier it is to refer to and discuss compared to the unnumbered ones.


Nobody mentioned being able to quickly look at an exception stack trace to find out where an exception occurred.

  • Really? OP states "referencing stack trace line numbers". Or are you both referring to different things?
    – StuperUser
    Sep 7, 2011 at 18:25
  • 3
    Oops... I missed that! Well... its important so it is worth reiterating! ;)
    – maple_shaft
    Sep 7, 2011 at 18:30
  • 4
    Well the question's been edited now, upvote ahoy!
    – StuperUser
    Sep 7, 2011 at 18:36
  • And of course, looking at logs (not necessarily from exceptions). All our logs index the file + line they originate from, incredibly handy! Sep 8, 2011 at 18:43
  • @maple_shaft, Actually even when you are not able to see lines, you can still do Ctrl-G (e.g. plain old notepad).
    – Pacerier
    Mar 25, 2015 at 17:11

Displayed line numbers are essential for paired-programming. There is no faster way to direct your pair's eyes to the code you are thinking about.

By extension, line-numbers are also extremely useful for code-reviews, both formal and informal.

  • +1: Hadn't considered paired programming (not surprising though as I'm definitely not a fan). However, the usefulness of line numbers in code reviews is pretty much turfed if you use an application for it (such as CodeCollaborator) Sep 7, 2011 at 18:23
  • I wasn't in the habit of line numbering until I'd done a bit of pair programming, now I'm in the habit of line numbering. +1 for getting me to realize this connection. Sep 7, 2011 at 18:29
  • 11
    Rather than saying "Lines 247 to 253," I find it faster to just highlight those lines, or point to them with my finger. I don't feel this answer is enough to justify the extra clutter. Sep 7, 2011 at 19:18
  • 1
    I'm stunned that this answer received 36 upvotes in 24 hours. Sep 8, 2011 at 17:48
  • @BlueRaja: not sure of pair programming either (though you could have both hands occupied), but when discussing from one desk to another, it definitely helps! There's something I don't understand in yyy.cpp at line 314, why do we need that ? Sep 8, 2011 at 18:39
  1. No, I like having the data to give me an idea of where is something in a file, especially if I'm looking at a big configuration file where it may not be easy to find that spot again.

  2. I may glance at the line number as a way for me to see how big is a file. If there are a few thousand lines of code in a file then it may be time to consider if that file should be broken up or something. I can also use it to judge how deep am I in a file if I have a ballpark of the file size and which numbers are on my screen. I like the idea of quantifying my location within the scroll bar, e.g. I'm in the top quarter of the file or 3rd quintile.

  • 1
    A few thousand? Sep 7, 2011 at 18:30
  • 4
    @Anthony: You should see loc per file in a game ;) Sep 7, 2011 at 18:32
  • 3
    @Anthony: sure. I've seen source files with 10k+ LOC, easily.
    – tdammers
    Sep 7, 2011 at 20:21
  • 1
    @tdammers, so have I. The issue is not whether these files exists, it's the point of when is the time to start reconsidering. In my view, that's normally well before a few thousand. It's well before a few hundred. In fact, once I start scrolling, I start to feel a bit antsy (doesn't mean I immediately refactor, mind you). Sep 7, 2011 at 20:46
  • 5
    @Anthony Pegram - I feel that a program should be well structured via functions/routines et cetera. The fact that they are all in the same file does not bother me; quite the opposite; I prefer them all in there instead of a plethora of files in one directory. Easier to diff too, IMO.
    – Rook
    Sep 7, 2011 at 21:50

I've come from a history of using editors with line numbers embedded in them. My thoughts on the matter? They're absolutely unneeded (I now use Vim with line numbers disabled). Think about this: Even when you do get stack traces and such, how many times do you manually look for the line using line numbers as opposed to ctrl+g (in most Windows editors) or :line-num in Vim?

Edit: Of course, this may be different for others, but 99% of the time, I use the latter.


One big thing: If you're using Visual studio or any ide with collapsible regions, line numbers give you an instant feel for how big an area is without expanding it. In addition, if you have some sort of logging directing you to a problem line, it's nice to not need to use a command when it's the line is right in front of you.


For whatever reason (cross compiling comes to mind) your compiler may not be integrated into your IDE. Therefore you need an absolute reference for where errors are found. (When you compile outside of your IDE)



The only time I've used line numbers is when a bug pops up and the stack trace tells me that it has happened at line x.

I've seen many professional developers working without line-numbers. So, I see no usage other than late referencing.


I like to have it when I use split screen in jEdit.

  • +1 It definitely helps to orient split screen work in the same file! There are few other ways to determine whether you are looking at the reference or the working area of the file.
    – Adam
    Sep 7, 2011 at 20:14

Yes, as @maple_host says, it's really convenient to do a "vi file.py +142" when I see an exception originating from code at that line number. Plus the other mentioned advantages with paired programming etc... It is always beneficial to have the line numbers on, on any editor. (I remember the vague compile error reported by MS VC++ 6 in one of the standard header files, line #blah!!.. It was actually a macro redefinition done by myself!!). Find and kill.

regards, Yati Sagade


I've found that current line highlighting can solve most "where are you looking" problems. But, the point about stack traces is critical.

Not the answer you're looking for? Browse other questions tagged or ask your own question.