Default Line Numbers in Eclipse

I rediscovered an “IDE Hot Topic” yesterday: line numbers in the editor. For me, this rediscovery started with a Tweet:

To me the single thing that epitomizes the shittyness of Eclipse as an IDE is that line numbers are off by default. #fb

Hopefully my kids aren’t reading this (I don’t like them to see misspellings).

Frankly, I don’t get why this is a big deal. When I require line numbers, I turn them on. It’s just a preference. I don’t understand how anybody can be so passionate about the default state of something that can be so easily changed (turning on line numbers is as simple as enabling the option in the context menu from the left-gutter of the editor). Frankly, there’s lots of other areas for improvement in Eclipse (like word wrap, for example). Like many other things in life, however, just because I don’t understand it, it doesn’t mean that it’s wrong.

I really don’t understand anything more than an infrequent need for line numbers in a code editor.

My response stirred up a few responses from some people for whom I have a great deal of respect. Clearly this is a bigger deal than I’m inclined to believe.

@waynebeaton Personally, it drives me nuts when I go to someone else’s desk and they don’t have line numbers turned on.

@waynebeaton Possibly a force of habit. I didn’t use debuggers when I first learned Java. 🙂 @irbull made some good arguments though I see.

@waynebeaton stack traces / build failures (from hudson), working remotely with someone (see line XXX).

@waynebeaton personally I always turn line numbering on.

@kingargyle @waynebeaton +1 for default line numbering in Eclipse

@waynebeaton its not like line numbers takes up huge amounts of space in your editor and when you debug in PHP its always needed 😀

RT @kingargyle @waynebeaton personally I always turn line numbering on < line numbers are for people who learnt to program in BASIC 🙂

I’m not sure if @alblue is coming out for or against line numbers. I learnt to program in BASIC on an Apple II Plus (who needs lower-case letters?), so line numbers are a familiar enough concept to me (I vividly recall the excitement of finding a utility that could renumber a BASIC file).

Ah, nostalgia. Excuse me while I queue up Van Halen – Van Halen.

Personally, I almost never need line numbers when I’m writing Java code. This is most likely a carry-over from my Smalltalk days. In my experience, the combination of my personal preference to write very concise methods (I tend to follow a seven-ish lines of code per method metric), great debugging support, and that cool ability to click on a line from a stack trace in the console or JUnit view seem to give me everything that I need for day-to-day development. Probably the only time that I might even want line numbers in Java is if I had to debug a bunch of stack traces from a production system. But code compiled for production deployment doesn’t always have line number information anyway…

PHP is a different story. It doesn’t take too long for me to turn on line numbers when I’m editing PHP code using the PHP Development Tools. Of course, I haven’t quite sorted out the debugging story in PHP (this is similar to @rcjsuen’s argument about familiarity: I didn’t have a debugger for so long that I got used to not having it).

I’m sure that there are many more opinions than have been expressed in this short exchange. Line numbers on by default was requested in Bug 191154, but didn’t generate any traction (i.e. nobody added themselves to the CC list, or voted) before it was closed as WONTFIX. Bug 293888 proposes to set this as the default in the Eclipse IDE for Education project (this–by the way–is a real easy bug to submit a patch for if you’re a student wanting to get involved with Eclipse).

In the end, it comes down to personal preference. But an “epitomizing feature”? I don’t buy it.

This entry was posted in Uncategorized. Bookmark the permalink.

8 Responses to Default Line Numbers in Eclipse

  1. Dave Rooney says:

    +1 CTRL+L If you need to jump to a line, use the shortcut. Learn your tool!

    BTW, it’s Apple ][, and that’s where I learned to program as well. Wasn’t as much of a Van Halen fan, and I also remember my jaw dropping when I could renumber my BASIC code! 🙂

    • waynebeaton says:

      I thought about the “Apple ][” and decided to go with “Apple II”. Not sure why. I think I’ll change it in the post 🙂

    • Ian Bull says:

      I use CTRL+L to jump to a line number, it’s not about ‘not knowing my tool’. But when you consistently work remotely with others we sometimes speak in ranges (lines XXX to YYY). Sometime people say “look a few lines above to ZZZ”). And sometimes I just need to know what line I’m on. I know the current line number is on the status bar so there is no reason to look to the margin to see it. Having said that, I don’t look to the status bar I look to the margin. Because I ‘use my tool differently from how you use your tool’, doesn’t mean I don’t know it ;-). (Queue the ‘use the tool jokes’) :D.

      One could argue that syntax highlighting should be turned off — learn the keywords in the language! But if a feature makes someone else more productive, then who am I to say their wrong. Personally I find that line numbers give me more context while I’m working. Having said all that, I don’t care if their on or off by default.

  2. Wayne, like you, I never use line numbers when I write code, but I do use them for almost every other purpose that pertains to code. Turning them on is always the first thing I do after starting a new workspace so I can understand the frustration over the default setting. I’ve never thought about word wrapping though.

  3. Bananeweizen says:

    If a Java developer needs line numbers because he thinks in “lines of code”, there is something wrong. Eclipse makes it so easy to think in code “artefacts” like classes, members, methods and so on that line numbers are completely irrevelant. I typically don’t even know whether a certain method is declared in the upper or lower half of my Java source code file because I never navigate text as such, I always navigate via F3, Ctrl+G, Ctrl+Shift+G or the outline tree items.
    Source “text” is just there because we inperfect humans haven’t yet invented a better input approach than keyboards…

  4. I do use line numbers, but not in the IDE, only when explaining code snippets “on paper” like in a wiki 🙂

    There’s something even better than line numbers: memory addresses! (None of you ever poked your machine codes directly into memory??)

    Seeing the old Apple reminds me: To actually learn programming I had to attend a US high-school, they had a TRS-80! When I returned to Germany the school finally had an Apple ][, too, but no teacher who could tell us anything about it, it’s embarassing, but that’s how it was.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s