[BlogEntry] Save 45 keystrokes every time you do logging in Eclipse


Sometimes the littlest changes make the biggest difference. I'm using this one all the time now.

I created a new code completion template in Eclipse. (Go to Window > Preferences, then Java > Editor > Templates.)

I added a new template called dbg in the java context. It is defined as

if( log.isDebugEnabled() ) {

Now, any time I want to log something, I just type dbg<Ctrl-space>, and I'm in position to type my logging message. (I just saved myself three minutes a day! Let's see, what am I going to do with that time? I think I'll learn a new language!)

Naming the template dbg is preferable to debug because there are no naming conflicts with dbg. If you name it debug, you have to confirm that you want the template named debug, as opposed to one of the many classes whose name starts with "Debug".

Leave a Reply

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

CommentLuv badge