How can I change line height / line spacing in Eclipse?

EclipseIdeEditor

Eclipse Problem Overview


I am using Eclipse for Java programming but lines in the editor look too close together.

I want to change the amount spacing/gap between lines. Is there an option in Eclipse that I can use to do this?

Eclipse Solutions


Solution 1 - Eclipse

I've cloned and installed the font from

https://github.com/andreberg/Meslo-Font

and made it my IDE editor font for Eclipse. Line spacing is much better now!

Solution 2 - Eclipse

After trying various alternative fonts, I've took original Consolas and increased line height in font editor, installed resulting ConsolasHigh font package into system and set it as default in Eclipse editor:

enter image description here

Check out: https://github.com/Salauyou/Consolas-High-Line

Solution 3 - Eclipse

You could configure a formatter (Preferences | Java | Code Style) to inject extra empty lines. Otherwise, you might be able to find a font (Preferences | General | Appearance | Colors and Fonts) with a lot of built-in whitespace. On Windows, I like 'consolas'--it's not particularly whitespace-y but it is a nice mono-spaced, readable font.

Solution 4 - Eclipse

you could put overly high characters in some comment somewhere, try "|ÄÁg$ÑĈђךןﭼژçÅẤДАБψ". As soon as Eclipse sees this in a file, it'll increase the line-separation for the whole file to properly display thos characters.

Solution 5 - Eclipse

Create your own bitmap font that uses all of the rows at the top of the font. It does work, and seems to save about up to 4 rows of pixels in a 17 point font. I did it as follows:

  • install otf2bdf
    • go to font folder, presumably in root terminal
    • Clone your favorite font (presumably a truetype font) using otf2bdf to the size you want it
    • install fontforge
    • edit the font so that it uses all of the rows above the line for the capital letters
      • typically there are about 3 lines of pixels that are left blank and that is why there is so much space between rows
      • should you wish you can also uses some of the rows below the line but I think these are typically used for lower case letters like y which drop below the line (not so important when programming)
    • install the font by:
      • saving it into one of the font folders such as /usr/local/share/fonts
      • updating the font chache In a root terminal with fc-cache -f -v
    • use the new font

Solution 6 - Eclipse

With respect to my response above, I can now provide more detail as to how to create the font, along with suggestions for creating a nicer font (starting with a truetype font):

  • Pick a truetype font you wish to use (I used an arial font)
  • Downloaded and install fontforge
  • Start fontforge and open the font file; I used a root terminal so that I could be sure to save the file in protected font folder
  • Select all the characters (Edit/Select/Select All)
  • Element Font Info PS Names
  • Specify names - I called it ArialMTVerticallyTighter; make sure you change all of the names on this tab or it may use the new font instead of the old font where you don't want it to
  • Element transformations transform
    • origin glyph origin
    • scale uniformly 120 %
      (more will be too big, use less if you want more spacing between lines)
  • Element General 1792 256 2048 Scale -142 150
  • OS/2 Metrics
    • Turn off is offset all over tab and t
    • Turn on really use typo metrics
    • 1792 512 1792 -512 0 1792 -512 0
  • File Generate Fonts - true type - into font folder - use new font name
  • File save (in case you screwed up so you can go back) to new name
  • Open new font file (in nautilus) with font viewer (by double clicking)
  • Install it
  • Start Eclipse
  • Set it as font in eclipse
    (window>preference>general>appearance>java editor>text font to new font)

Remember that the font size you see in eclipse for a particular setting e.g. 9 actually corresponds to about an 11 point font with less space between the lines

Solution 7 - Eclipse

On linux with gtk you can also play with a .gtkrc file. See here and here as examples.

Of course this doesn't help anything on windows :)

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
QuestionVamseeView Question on Stackoverflow
Solution 1 - Eclipsejosef.van.niekerkView Answer on Stackoverflow
Solution 2 - EclipseAlex SalauyouView Answer on Stackoverflow
Solution 3 - Eclipsesteamer25View Answer on Stackoverflow
Solution 4 - EclipseFarmboyView Answer on Stackoverflow
Solution 5 - EclipsePhil TroyView Answer on Stackoverflow
Solution 6 - Eclipseuser736786View Answer on Stackoverflow
Solution 7 - EclipseAndrew NieferView Answer on Stackoverflow