<< October 23, 2008 | Home | October 25, 2008 >>

Friday Java Non-Quiz: Sharing An Obscure IDE Trick Day

If you couldn't tell from last weeks questions that I'm running out of legitimate Java quiz questions, I don't know how loudly I have to say it.

Let's face it, Java is a pretty low-surprise language. Tedious maybe, but never mysterious. The contrast with C++ is astounding. I have to debug some JNI code yesterday, and when I got to the C++ part, I do indeed have to stare at lines like

int a = 0;
foo(a);
if (a == 1) bar();

and go, "That's impossible!"

Anyway, I did learn a new IntelliJ IDEA trick recently from the IDEA Refcardz. Thanks to CodeToJoy for alerting me to their existence.

It's Ctrl-Shift-UpArrow and Ctrl-Shift-DownArrow. What it does is to move things up or down within scope:

  • If the cursor is on a statement, it moves the statement relative to adjacent statements. The movement stops when the statement hits an opening or a closing brace of a if statement, while statement or a method definition.
  • If the cursor is on the name of a method or a field, it moves the method or field up or down relative to other methods or fields within its defining class.

What other IDE tricks have you learned recently? Can you do what I just described in your favorite IDE, Java or other languages?