How can I change line height / line spacing in Eclipse?
Asked Answered
T

8

70

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?

Twickenham answered 18/6, 2009 at 18:40 Comment(3)
Although this is not possible from within Eclipse as is pointed out in the answers, it is possible to change line spaceing in the SWT StyledText widget that Eclipse uses for its editors. So it would probably be trivial to make a plugin for this. Anyone wants to have a go on this one?Certain
Well, we can ask to implement it ! I ask for all of you to go and vote up this request ! bugs.eclipse.org/bugs/show_bug.cgi?id=26765Riba
For such a popular IDE, can't believe it lacks a rudimentary feature. :/Ravenna
H
30

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!

Huarache answered 1/3, 2013 at 11:45 Comment(2)
Nice one, Eclipse really rocks now :)Briareus
These fonts are great thanks so much :-) now I got the same line spacing as in Intellij/Phpstorm.Labelle
M
21

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

Michelson answered 15/10, 2015 at 9:59 Comment(3)
I love that you did this. I use Visual Studio for half of my work and having the fonts look as similar as possible makes work a lot easier.Hoary
Thank you. This is one thing that annoys me a lot when using Eclipse after having used Intellij for years where this is a configuration setting.Taneka
After 30 years coding, finally, this is the one that I really love. Thank you sooooooo much. It's our lovely consolas but increased line spacing.Doorknob
D
9

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.

Dirt answered 18/6, 2009 at 18:49 Comment(2)
In Visual Studio this font looks better because of additional empty pixel between lines. Yes, single pixel makes it look much better. Don't know how do the same in eclipse though.Isabelisabelita
I used to work with Lucida Console in Notepad++, but as Eclipse has smaller line-height and there is no nice way to change it, I found out DejaVu Sans Mono in this thread as a replacement for Eclipse. Looks nice with no need to have ClearType enabled.Victualer
C
9

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.

Contracted answered 8/4, 2011 at 9:12 Comment(2)
While this isn't a great solution to the original question, it did help me track down what was causing a particular file to open with bizarrely huge spacing between the lines. So thank you!Mathildamathilde
lol that is a funny trick, but bad hack anyways. Will totally ruin readibility .Pernell
T
6

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
Teerell answered 3/5, 2011 at 3:37 Comment(1)
Thank you very much! i use this to modify Unispace font and now its programmable!Pernell
S
5

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

Straub answered 3/5, 2011 at 19:47 Comment(0)
G
2

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 :)

Gomel answered 18/6, 2009 at 18:54 Comment(2)
second link xam.dk/blog/archives/81-Making-Eclipse-look-good-on-Linux.html is brokenVallation
This is the updated link: xam.dk/blog/making-eclipse-look-good-on-linuxPyelitis
C
1

As of Eclipse 4.27, now you can adjust the line spacing at Preference -> General -> Editors -> Text Editors

Be aware that HiDPI might causing inconsistency depending on your system

https://bugs.eclipse.org/bugs/show_bug.cgi?id=26765

https://github.com/eclipse-platform/eclipse.platform.text/pull/119

Consol answered 25/4, 2023 at 0:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.