Disclaimer: I'm a developper, and, as such, I'm lazy. So please don't expect this blog to be updated very often. Moreover, most of the time I don't really know what I'm talking about (it's not like software development is my job or something), so don't expect to find very useful stuff here either. Basically it's just some sort of semi public notepad with a few problems / things I encountered. Oh, and I'm French, so my english wont be any good... That said, nice reading!

eclipse: it’s in the details…

I think that knowing the little things that make Eclipse a great tool can really improve productivity. So I thought I’d compile the things I consider the most useful and make it public. If you have more tricks, I’d be happy to know them and add them to this list!

eclipse

Note : I’m using Eclipse Ganymede (i.e. 3.4.x) and I can’t tell for sure that all the things described later on are available on previous releases…

Note bis : I’ve always laid my hands on Galileo and all these tips are equally applicable.

Updates at the bottom !

You can also take a look to this list of almost-mandatory plugins here.




Finding resources the easy way (a.k.a. THE shortcut) : The most useful feature I’ve discovered so far is the CTRL+SHIFT+R shortcut. R as in Resource. When you hit this key-combo, a window pops out asking you what you are looking for. Just type the beginning of the java class / xml config file / properties file or whatever file is in your workspace and a list of resource matching your criteria will appear. This is very useful because you don’t need to know anything about where the file really is, and search it on the package explorer, moreover, it is really quick. But there is more : you can filter resources by pattern and you can “camel-case” what you are looking for (see below).

ctrlshiftr

CTRL+SHIFT+R, print it on your walls!

Going through interfaces with no pain : When you navigate through classes and you use a lot of interfaces, you can’t always rely on hyperlinking. To be proposed the choice between all implementations of an interface method, you can position your cursor on the method and hit CTRL+T. Very useful !

Camel case for less keystrokes : Having long descriptive class names or attributes is considered a good idea, but then you have to type them.. Of course there is auto-completion, but what if you have all your DTO classes prefixed by “Dto”? You can type less by camel-casing and not only in the Java editor. If you are looking for the ConfigurationSummaryAndTarifficationAction class, just hit CTRL+SHIFT+R and CSATA, and voilĂ  ! Same thing in many Eclipse dialog boxes.. always try to camel-case!

2 screens configuration : I use a 20″ flat screen in addition to my laptop and took the time to customize a few Eclipse “perspectives” to use every pixel of both screens. You can easily pop out panels and put them on the secondary screen. This is useful and allow you to diplay more information at the same time, without having to minimize / restore windows every 30s. Note that I have both 1 screen and 2 screens perspectives because when you don’t have your secondary screen, all the panels overlay on the same screen.

Launching Eclipse with a particular VM : If you don’t want to use the default VM to run your Eclipse, just create a shortcut and add this option to the path : -vm "E:Appjavajdk-6u6binjavaw.exe"

Keepin it clean : My package explorer view is crowded with files such as /target or /bin directories, and it makes it harder to locate the useful files. Well just activate a few filters and the annoying files will be history. You can ban files or directories by patterns or you can exclude particular resources from the view :

filter

Linking views : Using the “link with editor” button is (almost always) a good idea. When intensively using CTRL+SHIFT+R you tend to stop caring about how your projects are structured. Using this button synchronizes the package explorer and the file editor views by expanding nodes of the project tree and it helps locating files in the workspace.

link

that's the one!

CTRL+S‘ full potential : When you hit CTRL+S for saving your modifications, it automatically compiles the file, but you can make Eclipse do much more! Formatting the source code is something a lot of people do, just before saving. CTRL+F then CTRL+S. You can just make it automatic using the “save actions” menu. Cleaning the file from unused imports or unnecessary code is also a good idea, and even better you can convert old for-loops to 1.5 loops, it’s really time-saving.

Note that since 3.4, you can format only the lines you have edited, limiting conflicts if you don’t use the same formatting settings than your colleagues.

saveactions

here are my settings, not that the "configure" button leads to a whole bunch of other actions

Tuning the package explorer’s look : The package explorer default presentation can be greatly improved by tuning a few settings. What I use is a combo of “compressing packages names” and “hierarchical presentation”.

pkg

this?

compresspkg

or this?

You can use a pattern to compress packages names. For example “1.” will give you only the first letters of the parent packages separated by dots.

What also helps to keep a clear view of the workspace is using working sets to differenciate projects and to close a project when you know you won’t be working on it for a while.




First update : @2009/01/30

Mark occurences : a little feature, but very useful in everyday coding-life. This allows to highlight the occurences of a given variable. You can customize how you want to mark occurences in the preferences, in General > Editors > Text Editors > Annotations.

The settings you want are : “Write occurences” which corresponds to variable definition (I guess…) and “Occurences (jdt)” which corresponds to variable use, as you can see in the screenshot below.

It is very nice to be able to see in a jiffy where a variable is defined, and each line where it is used, believe me!

CTRL SHIT T, a.k.a. CTRL SHIFT R’s little brother : CTRL SHIFT R searches through your workspace resources, but with CTRL SHIFT T you’re able to search within every class of your workspace + your libraries ! If you need to see the content of a class but you don’t know in which jar it appears, just search it this way.

+ little precisions / additions to the previous “tips”




Second update : @2009/08/04

Well I’ve lost all my previous screenshots so I had to make some new (on my almost brand new macbook!), that’s all…




Well I think that it is more or less it for now. I may have forgotten a few tips, so I’ll probably update this post, I will gladly add your own tips!

Tags: ,

Comments are closed.