How to display line numbers in eclipse| line number color


This post covers an solving line numbers in Eclipse code editor for below things

  • display line numbers in eclipse editor by default
  • Eclipse line number disappear after setting “Show line settings” option
  • Changing default line number color in eclipse code editor

Eclipse Editor to show or hide line numbers

  • First , Go to Windows -> Preferences
  • It will open preference window
  • Go to General -> Editors -> TextEditors
  • check “show line numbers”

Please check below screenshot as shown below

eclipse show line numbers on code editor

Eclipse editor displays the lines as seen below

Eclipse enable disable line number

eclipse code editor show line numbers

This is another simple approach to add lines to eclipse code editor.

Here are the steps to do

  • Open any source code file, For example, Open java class file
  • Class file is displayed in Eclipse Code editor.
  • Next, Right click on the left side bar of an code editor
  • This will shows the context popup window as shown below
  • Check option - “Show Line Numbers” to enable code line numbers
Eclipse enable disable line number

eclipse short cut key to add line numbers in code editor

Using short cut keys in eclipse, We can enable/disable line numbers

To display the line numbers Click ctrl and F10 key, - it opens popup context window Select keyboard N key - It selects Show Line Numbers options and displays the line numbers

To hide the line numbers

Click ctrl and F10 key, - it opens popup context window Select keyboard N key - It uncheck Show Line Numbers options and line numbers are hidden.

Eclipse workspace settings to add line numbers by default

This will another option to configure at workspace settings

  • First Go to Project workspace folder
  • Select .metadata folder
  • Open the org.eclipse.ui.editors.prefs located under below folder structure
B:\myworkspace\.metadata\.plugins\org.eclipse.core.runtime\.settings\org.eclipse.ui.editors.prefs
  • Add or update the below code to this file
lineNumberRuler=true

Once changes done, Please restart eclipse to take effect.

How to change line number color in eclipse console?

  • First , Go to Windows -> Preferences
  • It will open preference window
  • Go to General -> Editors -> TextEditors
  • select “Line Number foreground” option
  • Change required color , Changed to Red color

Here is the screenshot

Change line number foreground color in eclipse

After changing the color, The line numbers color displayed as seen below How to Change line number  color in eclipse

THE BEST NEWSLETTER ANYWHERE
Join 6,000 subscribers and get a daily digest of full stack tutorials delivered to your inbox directly.No spam ever. Unsubscribe any time.

Similar Posts
Subscribe
You'll get a notification every time a post gets published here.