Categories
java

Eclipse Tips and Tricks…

Here is my second “Call For Help” needing help for an Eclipse Tip/Trick. Obviously, being a truly rookie with Eclipse these are basic questions now, but I’m sure they’ll be more challenging questions down the road. I guess this category could be helpful to people like myself, that are trying to get productive with Eclipse.

How can I quickly get a pre-defined code block/line/snippet into a Java class in Eclipse? With Vim I could define a “bit” of code in my .vimrc file and link it to a string. When I type the string it would get replaced with the code from my .vimrc.

So for a simple System.out.println( “” ); statement I would simply type jso+Spacebar and the “jso” would be replaced with “System.out.println( “” );”. The best part was I could control where my cursor would be and if I would be in edit mode or not.

I know this can be done easily in Eclipse. The problem is me finding out how to do it? Finding out what is already defined for me and how to write my own custom code “snippets”.

I’ll report back when I’ve “cracked the code”…… That was bad, but it got a smirk out of me. Sorry.

5 replies on “Eclipse Tips and Tricks…”

It’s all in the templates.
Window -> Preferences -> Java -> Editor -> Templates.

Define a name ‘jso’ for context of ‘java’ and a pattern of …

System.out.println(“${cursor}”);

Now, when in a java editor, type jso and hit Ctrl-Space (which is your Content Assist), at that point the jso will be expanded.

Incidentally, there is a vi plugin for eclipse available too. http://www.satokar.com/viplugin/index.php

Yes, Joakim is obviously an Eclipse guru. Joakim, I think I just need to give you an userid and password here on erik.weibust.net and just let you write my post updates instead of putting your stuff in the comments. THANKS!

Eclipse Hmm…

I have been using the heck out of Eclipse since my last “Eclipse Hmm…” post. I really like Eclipse. I’m starting to feel very productive with it. I like it so much that I don’t even long for the “good…

Leave a Reply

Your email address will not be published. Required fields are marked *