How to change line height in NetBeans’ editor

After changing font size in editor in NetBeans 6.5, the line height (line spacing) all of a sudden grew to about 2 “normal lines”, and didn’t change back even when I returned to the original font size.

The only work-around I found was to edit manually the editor’s configuration file (since this option is not available via GUI).
The file org-netbeans-modules-editor-settings-CustomPreferences.xml can be found in ~/.netbeans/6.5/config/Editors/Preferences (on Windows, it’s in {install_dir}\ide10\config\Modules ). If it’s not there, change any editor settings in NetBeans IDE, and it’ll create it.

Open this file in your favourite text editor, and add the following code right before the last line (right before the </editor-preferences> tag):

<entry javaType="java.lang.Float" name="line-height-correction" xml:space="preserve">
    <value><![CDATA[0.7]]></value>
</entry>

And that’s it! Restart the NetBeans IDE, and all should look much better. Happy coding!

Another solution, thanks to Mark :

  1. Install sun-java6-jdk
  2. Uninstall open-jdk
  3. Reinstall NetBeans

49 responses to “How to change line height in NetBeans’ editor

  1. Thanks a lot!
    I already got used to the two-space margins, but today the line height went up to the whole height of my monitor :-(

    I’m on ubuntu ibex and have set the internal Netbeans font to monospaced 13.

  2. Thanks for that ! I am French and i searched for a long time a solution to this problem.

    for referencing :
    Corriger hauteur de ligne netbeans 6.5 taille police

  3. MWUAHAHA!

    Thanks for this article… but I’ve got something even better for you now!

    Before when I tried installing Netbeans, I got it from apt-get but it didn’t come with C++ support (plus it was only version 6.1), so I downloaded it from there site instead… and then I ran into this line-height problem.

    What I didn’t realize was that when you download it from apt-get it also installs JDK. When I was reinstalling Ubuntu on my other computer, I skipped the apt-get step and got it straight from the site, which doesn’t come with JDK. So I fumbled around looking for JDK for awhile, until I found ‘sudo apt-get install sun-java6-jdk’. Turns out, this also fixes the line-height problem AND your text isn’t stupidly top-aligned. Looks much nicer now!

    SUMMARY:
    sudo apt-get install sun-java6-jdk
    fixes the problem properly (you may need to uninstall your old JDK, I don’t know — you’re probably using OpenJDK)

  4. Mark gave the correct answer!
    Line-height is not the only problem, it is the space under the line which is annoying and almost made me switch to eclipse.
    Thanks Mark.

  5. Woaw, thanks a lot man! :D

    I just installed NetBeans 6.5 in my Ubuntu 9.04 system and thought it looked…”weird” compare to how Eclipse 3.2 looked. Couldn’t really understand what the weird thing was, thought it was the resolution or something that made me feel like there wasn’t any space for all my code :P
    THEN I understood that it was the line height that was weird, glad I found this blog-post, couldn’t find any settings for the line height in the NetBeans options!

    Thanks again!
    //Chris

  6. Pingback: Bios Elemental | How to change line height in NetBeans’ editor

  7. If you use Marks way, you might have to run:

    sudo update-java-alternatives –set java-6-sun

    if you have gcj or some other jdk installed.

    Thanks for the hints!

  8. That wasn’t enough, I also had to edit “/usr/share/netbeans/6.5/etc/netbeans.conf” to point to “/usr/lib/jvm/java-6-sun”. Re-installing netbeans didn
    t fix that.

  9. Great thanks, it works, NetBeans is my favourite editor and this problem irritated me.

  10. Yesai!

    That worked like a charm. I’m using 6.7 now but I suspect that this fix would have corrected the humongous toolbars I was seeing when I had 6.5 installed.

    Thanks Man

  11. “That wasn’t enough, I also had to edit “/usr/share/netbeans/6.5/etc/netbeans.conf” to point to “/usr/lib/jvm/java-6-sun”. Re-installing netbeans didn
    t fix that.”

    This is all you have to do after you install sun-java6-jdk. No need to re-install

    Thanks for the solution guys!

  12. Thanks! Just what I needed.

    Got it to work by just installing sun-java6-jdk and then editing “usr/share/netbeans/6.5/etc/netbeans.conf” line 19 from:
    netbeans_jdkhome=”/usr/lib/jvm/java-6-openjdk”
    to:
    netbeans_jdkhome=”/usr/lib/jvm/java-6-sun”

    Thanks so much!

  13. Other way to fix this is to change your font from monospaced to for example: Dejavu Sans Mono (size 13 is nice). This is, if you want to use openjdk.

    Tip:
    You can switch from java-6-sun and java-6-openjdk if in your usr/share/netbeans/6.5/etc/netbeans.conf (as suggested by Elpinoine) and write:
    netbeans_jdkhome=$JAVA_HOME

    Then just set the environment variable JAVA_HOME=/user/lib/…(whatever).

  14. Thanks for this. Starting to play around with NetBeans after getting tired of Eclipse and the line height issue was really putting me off, now it’s not! Thanks.

  15. Pingback: Netbeans and Ubuntu 9 Jaunty « Blog a Thon

  16. Thanks so much for this, you saved my life. :)

    Now I just wish that the Netbeans dev team would sort this bug out. It’s been haunting me since NB 6.5 an it’s still haunting me in NB 6.7.

    *sigh*

  17. I found the file in a sub-folder:
    ~/.netbeans/6.5/config/Editors/text/x-make/Preferences

    I just copied the folder Preferences to
    ~/.netbeans/6.5/config/Editors/Preferences

    and it worked.. thanks.. Good post!!
    Christian.

  18. Pingback: netbeans line height | Arkady Smirnov

  19. For Netbeans 6.8, on Windows XP, I found the xml file on:

    %USERPROFILE%\.netbeans\6.8\config\Editors\Preferences\org-netbeans-modules-editor-settings-CustomPreferences.xml

    Hope it helps anyone!

  20. Tools/options/fonts/

    Change whitespace to a smaller value. Inherited+10+bold seemed to work for me.

  21. Muhammed :

    its not work on NetBeans 7.0

    Sorry, no idea what to do on NetBeans 7. I’ve dropped NetBeans some time ago, due to its (for me) many glitches; I’m now on Vim, Emacs, Qt, and Komodo.

  22. JustChecking :

    Muhammed :
    its not work on NetBeans 7.0

    Sorry, no idea what to do on NetBeans 7. I’ve dropped NetBeans some time ago, due to its (for me) many glitches; I’m now on Vim, Emacs, Qt, and Komodo.

    For NetBeans 7.0 on the Mac goto to NetBeans -> Preferences. Then open Fonts & Colors. Under Category scroll down to Whitespace. I use Menlo 12 and I have changed my whitespace to Menlo 24( it shows as “Inherited+24″ ).

    Hope this helps!

  23. Jason,
    Thanks for that… Your Netbeans 7 fix for line spacing / height worked perfectly for me.

  24. For Netbeans 7.2.1, on Windows VISTA, the xml file is on:

    %USERPROFILE%\AppData\Roaming\NetBeans\7.2.1\config\Editors\Preferences\org-netbeans-modules-editor-settings-CustomPreferences.xml

    It works as well as 6.9.1.

    Thanks.

  25. Terrific info, but I have got a quick question… who made your template?
    Did you build it yourself or is this a premium theme?
    If it is totally free, I’d like to get it, it is precisely the kind of template I need for my upcoming blog.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s