{

How to display line numbers in eclipse| line number color


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

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

Eclipse Editor to show or hide line numbers

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

Please check the 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 number

It is another simple approach to add lines to the 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 the Eclipse Code editor.
  • Next, Right-click on the left sidebar of a code editor
  • This will show 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 the 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 unchecks Show Line Numbers options, line numbers do not show.

Eclipse workspace settings to add line numbers by default

It is another option to configure workspace settings.

  • First, Go to the 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 are done, Please restart the eclipse to take effect.

How to change line number color in the eclipse console?

  • First, Go to Windows -> Preferences
  • It will open the preference window
  • Go to General -> Editors -> TextEditors
  • select the “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.