How can I show line numbers in Eclipse?

EclipseConfiguration

Eclipse Problem Overview


How can I show line numbers by default in Eclipse?

Eclipse Solutions


Solution 1 - Eclipse

Window → Preferences → General → Editors → Text Editors → Show line numbers.


Edit: I wrote this long ago but as @ArtOfWarfar and @voidstate mentioned you can now simply:

Right click the gutter and select "Show Line Numbers":

http://i.stack.imgur.com/KP7mH.png" width="350"/>

Solution 2 - Eclipse

If this doesn't work it may be overridden by your current settings. You can right-click in the bar to the left of the code where line numbers would normally appear and turn them on with the context menu.

Screen showing this context menu

Solution 3 - Eclipse

Update November 2015:

In Eclipse Mars 4.5.1, line numbers are (annoyingly) turned off by default again. Follow the below instructions to enable it.


Update December 2013:

Lars Vogel just published on his blog:

Line numbers are default in Eclipse SDK Luna (4.4) as of today

(December 10, 2013)

> We conducted a user survey if users want to have line numbers activated in text editors in the Eclipse IDE by default.
The response was very clear:

YES : 80.07% (1852 responses)
NO  : 19.93% (461 responses)
Total  : 2313
Skipped:   15

> With Bug 421313, Review - Line number should be activated by default, we enabled it for the Eclipse SDK build, I assume other Eclipse packages will follow.


Update August 2014

Line number default length is now 120 (instead of 80) for Eclipse Mars 4.5M1.
See "How to customize Eclipse's text editor code formating".


Original answer (March 2009)

To really have it by default, you can write a script which ensure, before launching eclipse, that:
[workspace]\.metadata\.plugins\org.eclipse.core.runtime\.settings\org.eclipse.ui.editors.prefs does contain:

lineNumberRuler=true

(with [workspace] being the root directory of your eclipse workspace)
Then eclipse will be opened with "line numbers shown 'by default' "


Otherwise, you can also type 'CTRL+1' and then "line", which will give you access to the command "Show line numbers"
(that will switch to option "show line numbers" in the text editors part of the option.

Or you can just type "numb" in Windows Preferences to access to the Text Editor part:

show line number

Picture from "How to display line numbers in Eclipse" of blog "Mkyong.com"

Solution 4 - Eclipse

As simple as that. Ctrl+F10, then N, to Show or hide line numbers.

Reference : http://www.shortcutworld.com/en/win/Eclipse.html

Solution 5 - Eclipse

Slight variation on Mac OSX:
Eclipse → Preferences → General → Editors → Text Editors → Show line numbers

Solution 6 - Eclipse

in this file

[workspace].metadata.plugins\org.eclipse.core.runtime.settings\org.eclipse.ui.editors.prefs

make sure the parameter

lineNumberColor=0,0,0

is NOT 255,255, 255, which is white

Solution 7 - Eclipse

Windows → Preferences → General → Text Editors → Show numberlines

Solution 8 - Eclipse

Go to Windows → Preferences → General → Text Editors → Show numberlines. Click OK, then Apply changes. Then it will show the line count automatically.

Solution 9 - Eclipse

one of the easy way is using shortcuts like : Ctrl+F10, then press n "it show line number and hide line numbers.

Solution 10 - Eclipse

The top answer is good but you can also bind it to a key ( shorcut ) to toggle it..

Window > Preferences > Keys then enter "Line Numbers" in filter and bind it to a key.

I use CTRL + S + L.

Solution 11 - Eclipse

Open Eclipse

goto -> Windows -> Preferences -> Editor -> Text Editors -> Show Line No

Tick the Show Line No checkbox

Solution 12 - Eclipse

click on window tab and click on preferences

click on window tab

do this and check show line number

check show line number

Solution 13 - Eclipse

the eclipse changes the perferences's position

to eclipse -> perferences

Solution 14 - Eclipse

On a Mac do this:

cmd + , or ADT -> Preferences 

Expand General -> Editors ->Text Editors

Check box: Show line numbers

enter image description here

Solution 15 - Eclipse

Eclipse has a search feature in the top left box of the Preferences. Type in 'line numbers' in that search box, and presto...

In case you're tired of googling each time you forget...

Solution 16 - Eclipse

this will be the appropriate solution for asked question:

String lineNumbers = AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER; EditorsUI.getPreferenceStore().setValue(lineNumbers, true);

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSayed BondokView Question on Stackoverflow
Solution 1 - EclipsefbernierView Answer on Stackoverflow
Solution 2 - EclipsevoidstateView Answer on Stackoverflow
Solution 3 - EclipseVonCView Answer on Stackoverflow
Solution 4 - EclipseshabyView Answer on Stackoverflow
Solution 5 - EclipsecrsierraView Answer on Stackoverflow
Solution 6 - EclipseAntonio LeiteView Answer on Stackoverflow
Solution 7 - EclipseHANUView Answer on Stackoverflow
Solution 8 - EclipsebhejaFryView Answer on Stackoverflow
Solution 9 - EclipseArul PandianView Answer on Stackoverflow
Solution 10 - EclipseDevCView Answer on Stackoverflow
Solution 11 - EclipseUjjwal RoyView Answer on Stackoverflow
Solution 12 - EclipseAdiiiView Answer on Stackoverflow
Solution 13 - Eclipseuser1144651View Answer on Stackoverflow
Solution 14 - EclipseMike ZrielView Answer on Stackoverflow
Solution 15 - EclipsewizurdView Answer on Stackoverflow
Solution 16 - EclipseRTAView Answer on Stackoverflow