tool - How can I show line numbers in Eclipse?




show line numbers in sts (12)

How can I show line numbers by default in 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":



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...


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.


On a Mac do this:

cmd + , or ADT -> Preferences 

Expand General -> Editors ->Text Editors

Check box: Show line numbers


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


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.


Windows → Preferences → General → Text Editors → Show numberlines


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


the eclipse changes the perferences's position

to eclipse -> perferences


this will be the appropriate solution for asked question:

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







configuration