69

My question is very similar to Stack Overflow question Gigantic Tabs in Eclipse on Ubuntu.

I have tried the solutions presented, but they appear to be old. I have found a solution that nicely handles the toolbar and menus, but not a solution that reduces the size and padding of the disproportionately large tabs (and label) within the panes (see the tab "Package Explorer" in the screen below).

I am happy with the way my OS-wide GTK theme is customized and don't want to change that. Is there a quick fix to reduce the tab sizes of the panes in Eclipse?

I'm using Eclipse for Mobile Developers (Juno) on Ubuntu 12.04. I'll also mention that I really like the way Eclipse appears out of the box in Windows 7, so something similar to that would be ideal.

Here are the eclipse specific GTK styles I'm using:

style "eclin" {
    GtkButton::default_border={1,1,1,1}
    GtkButton::default_outside_border={1,1,1,1}
    GtkButtonBox::child_min_width=0
    GtkButtonBox::child_min_heigth=0
    GtkButtonBox::child_internal_pad_x=0
    GtkButtonBox::child_internal_pad_y=0
    GtkMenu::vertical-padding=1
    GtkMenuBar::internal_padding=1
    GtkMenuItem::horizontal_padding=4
    GtkToolbar::internal-padding=1
    GtkToolbar::space-size=1
    GtkOptionMenu::indicator_size=0
    GtkOptionMenu::indicator_spacing=0
    GtkPaned::handle_size=4
    GtkRange::trough_border=0
    GtkRange::stepper_spacing=0
    GtkScale::value_spacing=0
    GtkScrolledWindow::scrollbar_spacing=0
    GtkExpander::expander_size=10
    GtkExpander::expander_spacing=0
    GtkTreeView::vertical-separator=0
    GtkTreeView::horizontal-separator=0
    GtkTreeView::expander-size=12
    GtkTreeView::fixed-height-mode=TRUE
    GtkWidget::focus_padding=0
    font_name="Liberation Sans,Sans Regular 8"
}

class "GtkWidget" style "eclin"
    style "eclin2" {
    xthickness=1
    ythickness=1
}

class "GtkButton" style "eclin2"
class "GtkToolbar" style "eclin2"
class "GtkPaned" style "eclin2"

Here is a screenshot of what my IDE looks like with the huge tabs:

Eclipse Juno IDE with tabs too big

Community
  • 1
  • 1
Andy
  • 2,154
  • 3
  • 20
  • 16
  • @eicto, you should make this a full answer, and mention that you have to select GTK as the window manager. – Ajax Dec 18 '12 at 01:54
  • 2
    At least since eclipse Mars there is a dedicated font setting for this: Go to Preferences -> General -> Appearance -> Colors and Fonts -> View and Editor Folders -> Part title font – StefanQ May 13 '16 at 14:28

7 Answers7

96

You can edit Eclipse's CSS instead of messing with the GTK theme.

In your Eclipse directory find the file plugins/org.eclipse.platform_4.2.*/css/e4_default_gtk.css (there's an * in there, because I guess that the version may change in the future or may be different already). In this file there's a CSS class:

.MPartStack {
    font-size: 11;
    swt-simple: false;
    swt-mru-visible: false;
}

And you have two possible solutions:

  1. change font-size to something smaller
  2. just comment out or remove font-size from this class (works well for me)

And that should do the trick.

konradstrack
  • 2,852
  • 2
  • 18
  • 23
  • 1
    Thank you! +1 for conciseness too :). After knowing what to search for, I was able to find the following documentation for anyone else with a similar problem: http://wiki.eclipse.org/Eclipse4/CSS – Andy Aug 07 '12 at 17:35
  • 1
    In 4.2, there is a gui option under general -> appearance to use GTK theme instead of classic. – Ajax Dec 18 '12 at 01:43
  • 1
    @Ajax: You are right, and I had to do this to use the custom gtk theme I posted, however the question (and solution) only addresses the tabs which isn't handled by the theme. – Andy Dec 18 '12 at 23:29
  • No worries. Just adding to the knowledge base. The GTK theme in 4.2 actually seems to make eclipse almost unusably slow, but for the purpose of OS integration, it's handy to know. – Ajax Dec 30 '12 at 11:42
  • 3
    I changed the `font-size` to `9` and I can see the font size become smaller after a restart, but the tab height remained the same. I changed the `swt-tab-height` and `padding` to all `0px` and yet there was no difference. Is there another setting to change? – haridsv Mar 04 '13 at 14:42
  • Do you know how to do that in fedora eclipse 3.4.2? yeah its old but cant do anything about it – Templar Jun 19 '13 at 11:37
  • 1
    @haridsv - Did you find a solution to the tab issue? I'm also not seeing smaller tabs, only smaller fonts in an huge tab. – technocrat Oct 27 '13 at 03:00
  • @technocrat I don't think so, I will have to check if I did something or if I just got used to it. – haridsv Oct 27 '13 at 16:07
  • @technocrat I just checked my eclipse setup, and my tab height feels normal. Since the time I upgraded to Juno, I remember only changing the `font-size`, so I am pretty sure I did nothing in this regard. My guess is that something got fixed now in the platform, so if you are not using Juno or a newer release, you could just try upgrading. – haridsv Oct 28 '13 at 04:50
  • @haridsv Hrm, yea I'm not sure then. I'm using Kepler. – technocrat Nov 06 '13 at 00:20
  • OMG it looks so beautiful now I wanna cry. Was bugging the living crap out of me! – Dmitriy Jun 10 '14 at 20:54
  • It doesn't work for me. Only makes the fonts smaller. – omerfarukdogan Mar 24 '15 at 17:07
  • To Eclipse 4.5 (mars) the path is: /plugins/org.eclipse.ui.themes_1.1.0.v20150511-0913/css – josivan Jul 05 '15 at 00:36
  • For mars, using the new installer, i found the file in my home directory: ~/.p2/pool/plugins/org.eclipse.ui.themes_1.1.0.v20150511-0913/css – dan carter Oct 29 '15 at 22:51
  • For eclipse mars this solution is not enough -> http://stackoverflow.com/a/32229790/1938607 – Andrea Ratto Nov 19 '15 at 23:52
61

Style of tabs can be changed in Eclipse 4.2 by editing CSS. You can change styles directly in Eclipse Preferences window after installing the E4 CSS editor plug-in.

Go to menu Help > Install new software, then install E4 CSS editor (Incubation) plug-in using Eclipse 4 update site (add this link: http://download.eclipse.org/e4/updates/0.12).

After restart, go to Window > Preferences, General > Appearance and now you can edit styles here for any selected theme.

I am using this style for tabs:

.MPartStack {
  font-size: 9;
  font-family: Liberation Sans;
  swt-tab-renderer: null;
  swt-tab-height: 22px;
  swt-selected-tabs-background: #FFFFFF #ECE9D8 100%;
  swt-simple: false;
  swt-mru-visible: false;
}

You can specify tabs height using the swt-tab-height option. It's value sets tab height ignoring the font size.

akond
  • 15,865
  • 4
  • 35
  • 55
Stanislav Mamontov
  • 1,734
  • 15
  • 21
  • 2
    Setting `swt-tab-height` is more useful than changing the `font-size` only, thanks, @MrSmith42 every wasted pixel counts unless it is a 4K display :) – Mustafa Oct 09 '13 at 13:24
  • 1
    Eclipse Kepler doesn't like parsing comments in the css. Also used the last recommendation here: http://techtavern.wordpress.com/2008/09/24/smaller-font-sizes-for-eclipse-on-linux/ (Overwriting the theme) to make my package explorer font size smaller. I also referenced here: https://gist.github.com/andrioli/3825078 for smaller toolbars. All three of these provided a great minimalist approach for eclipse. – technocrat Oct 27 '13 at 03:08
  • watch out, you can minimize swt-tab-height so that aditional tab commands/functions wont show. – Augustas Mar 12 '14 at 10:41
  • Where is this __CSS editor__ now (summer of 2014)? Cannot find it in any repo or the market. – Redsandro Jun 25 '14 at 15:19
  • @Redsandro, you just should edit the same file as in accepted answer. For me it was /usr/share/eclipse/plugins/org.eclipse.ui.themes_1.0.0.v20140604-1608/css/e4_default_gtk.css. I've just tested it on new Eclipse Luna, still works fine ;) – Stanislav Mamontov Jul 02 '14 at 17:49
  • On eclipse Neon, I was able to find the plugin using update site: [e4 v0.16 updates](http://download.eclipse.org/e4/updates/0.16) The plugin to look for is "E4 CSS editor (Incubation)". Once installed, I was able to edit the Dark theme as follows: `.MPartStack, .MPart { font-family: '#org-eclipse-ui-workbench-TAB_TEXT_FONT'; font-size: 8; swt-tab-height: 22px; }` – troyfolger Apr 04 '17 at 21:58
13

I also wanted to reduce especially the horizontal space in order to fit more tabs, as Eclipse lacks multi-row tabs.

These instructions will go for any platform (not limited to e.g. Ubuntu/GTK).

What I did was:

  • Reduced the font size
  • Changed font to something horizontal-compact
  • Removed the X (close tab) button

...yielding the following result on my system (Win 7):

Screenshot with modified tabs

...and this is how it's done:

  1. Check what CSS layout you're using: Preferences->General->Appearance-> check value of 'Theme:' listbox

  2. Open the corresponding file in <eclipse folder>\plugins\org.eclipse.platform_<your version>\css, e.g. e4_default_win7.css

  3. Modify .MPartStack entries to set font size and font, e.g.:

    .MPartStack {
        font-size: 8;
        font-family: 'Arial Narrow';
        swt-simple: true;
        swt-mru-visible: false;
    }
    
  4. Add the following entry to remove the X (close icon):

    CTabItem {
        swt-show-close: false !important;   
    }
    

That's it!

Carl
  • 937
  • 10
  • 21
8

Eclipse is now (4.5 Mars) defaulting to GTK3 on Linux. For 4.6 a fix seems to be alredy merged.

Changing SWT_GTK3 environment variable works for Eclipse Mars:

$ export SWT_GTK3=0

or set that variable inline with running eclipse

$ SWT_GTK3=0 /path/to/eclipse/eclipse

To kill it dead just drop this in the root as eclipse.sh:

#!/bin/bash
SWT_GTK3=0 exec env "${0%.sh}"
Andrea Ratto
  • 815
  • 1
  • 11
  • 23
marioosh
  • 27,328
  • 49
  • 143
  • 192
  • 4
    To force **Eclipse Mars** to use GTK 2, instead of exporting `SWT_GTK3=0`, you could also start up Eclipse with `{install_path}/eclipse --launcher.GTK_version 2`. To see the version, in Eclipse go to **Help>About Eclipse>Installation Details>Configuration** Tab, and look for `org.eclipse.swt.internal.gtk.version`. – frIT Jan 02 '16 at 14:56
  • This solution also solves the issue where the buttons are very large (along with the tool bars) This works with the newest (as of Oct 2016) version of Eclipse, Oxygen – mpop Oct 07 '16 at 16:09
  • @fr13d, THANKS, setting that switch worked for me. And it is a lot easier than creating separate config files and other headache... – Svenv Mar 02 '17 at 19:33
1

You may try the theme from https://github.com/jeeeyul/eclipse-themes.

After install this theme, apply it by choosing the theme in Window > Preferences > General > Appearence > Jeeeyul's themes.

And to solve the large tab problem, please refer to https://github.com/jeeeyul/eclipse-themes/wiki/Linux-Huge-Toolbar-Problem.

It's easy and beatiful. Enjoy it!

phil
  • 2,558
  • 1
  • 19
  • 23
0

An alternative way is to select:

System settings > Universal access > Text size as small.
Stephan
  • 41,764
  • 65
  • 238
  • 329
0

You can edit all small details about tab size here:

image

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92