Eclipse’s Awesome Block Selection Mode

This post is about an awesome Eclipse feature, that is completely underestimated and hidden in the menu. Yet, it is so useful in so many situations. The awesome “Block Selection Mode” which can be toggled through Alt-Shift-A on Windows. Here’s an example challenge for the Block Selection Mode:

Is there any way I can write (copy-paste) nicely-formatted SQL queries in Java string literals using Eclipse?

And my answer:

Step 1: Paste

Paste your formatted SQL statement verbatim into your Java file

Step 2: Write opening quotes

Notice the highlighted button, the sixth from the left. That’s the awesome “Block Selection Mode” (Alt-Shift-A on Windows). It lets you write opening quotes on each selected line at the same position

Step 3: Write closing quotes and concatenation

Apply the same technique for the closing quotes and the concatenation sign (`+`)

Step 4: Fix the semi-colon

No comment needed here.

Awesome Eclipse feature, no?

Nice Tutorial for Creating an External DSL with Xtext

When blogging about DSLs, I’m mostly blogging about internal domain-specific languages, because jOOQ is a good example for internal DSLs. But external domain-specific languages are an interesting topic as well. As an external DSL does not depend on any host language (e.g. Java), it can be much richer in syntax and expressivity. On the other hand, you need tools to parse, compile and maybe even interpret / run them.

Here’s a very interesting blog post showing how to create an external DSL with Xtext, Eclipse’s DSL tool chain. It creates a simple DSL to describe video game control flows and shows how Eclipse Xtext immediately provides an editor with all sorts of IDE features for that custom DSL:

http://www.altdevblogaday.com/2013/07/19/creating-powerful-languages-with-xtext

JDEclipse: A must-have Java Decompiler

I have recently discovered this new, must-have Eclipse plugin, which is very useful for those third-party libraries whose source-code you can’t easily find or link into your Eclipse: JDEclipse.

It doesn’t only decompile byte code into Java code, it does so extremely well, keeping line numbers at the correct place, such that you can actually debug through the decompiled source code and set breakpoints that actually work.

Read more about JDEclipse here:
http://mchr3k.github.com/jdeclipse-realign/

Note that of course you shouldn’t decompile any code whose license doesn’t allow you to do so…

Learn Eclipse Keyboard Shortcuts Easily

Disclaimer: Some users experienced this plugin to break their Eclipse Juno (see comments). Use at own risk!

Using keyboard shortcuts can vastly increase your productivity. Instead of switching between keyboard and mouse all the times, trying to figure out where that mouse cursor is, left/right clicking your way through context menus nested several levels deep, you could’ve just hit AltShift-I, for instance, for inlining constants, variables, methods, etc… But how to remember the most important ones? Tricky…

Except if you’re using the mousefeed Eclipse plugin:
http://www.mousefeed.com/ (ignore the bad page layout)

This plugin will show a very annoying and obnoxious, big popup indicating the keyboard shortcut that you could’ve used just now instead of clicking through Eclipse menus with your mouse. For instance:

A shortcut reminder
A shortcut reminder

This will eventually annoy you so much that you’ll willingly use the suggested keyboard shortcut just to make the popup go away! And the best thing is, you’ll only learn the shortcuts for those actions that you really execute very often.

Be productive again!

Must-have Eclipse plugin: AnyEdit Tools

On fresh Eclipse installations, I usually feel a bit naked, until I realise that this lovely little plugin is not part of Eclipse itself. It’s called AnyEdit tools, and it features the following nice things:

  • Convert Tabs <-> Spaces
  • Convert: Chars <-> Html entities
  • Convert: Camel <-> Underscores
  • Convert: Capitalize
  • Convert: Invert Case
  • Convert: To Upper Case
  • Convert: To Lower Case
  • Convert: From/To Base64
  • Compare/Replace with Clipboard
  • Compare/Replace with Workspace File…
  • Compare/Replace with External File…
  • Compare/Replace with Opened Editor…

Most of these features are available through shortcuts, too. Download it, too and you’ll never want to miss it again!

AnyEdit Tools screenshot
AnyEdit Tools screenshot