IDEA series (ix) selective actions
Working with selections
Please note that this is for Groovy and Grails development on Mac OS X with Swiss-german keyboard layout and default keymap, so the keybindings may differ on your machine. (For Windows, you most often can replace Cmd with Ctrl)
We have seen the editing support for lines, combined with selections. This part is more specifically about working with selections.
know your keyboard navigation
first of all, it is very helpful to familiarize yourself with your OS-specific keyboard commands for moving the cursor around and with the Shift key pressed, doing a selection. On Mac that is Cmd left/right for begin/end of line and Alt left/right for jumping over words. Of course you can use the mouse for selections but once you master the keystrokes, you will be faster and more precise.
Cmd W (Shift for reverse)
is widening the current selection. That is, if you already have a selection, it expands it to the next enclosing syntactical scope (expression, statement, block). Without a selection, it starts a selection at the caret.
Mac users may expect Cmd W to close the current editor (internal window) as typical for mac applications, but that functionality is mapped to Cmd F4 in the standard keymap (somehow resembles the Windows keystroke).
I use widening most of the time to select a small expression precisely – often for later use in a refactoring. I start in the middle of the code and hit Cmd W repeatedly.When selecting a larger block, let’s say a method or a whole class body, it’s efficient to place the cursor just after the opening brace and hit Cmd W just once to select the whole block.
Cmd Alt T
surrounds the selection (or current line if there is no selection) with a live template. This features spares you the need for fiddling around with cursor positioning to put some code into an “if” block and the likes. I even made my own templates for surrounding a selection with parentheses, brackets (to make a literal Groovy list), braces (to make a closure or block), single quotes, and double quotes.Especially putting quotes around a selection is nice since otherwise IDEA sometimes inserts pairs of quotes when it shouldn’t.
Context menu -> Compare with Clipboard
when you have a selection and open the context menu (right mouse click) you’ll see a “Compare with clipboard” entry, which opens the internal diffing view. Nice.
keep groovin’
Dierk
@mittie












Tweets that mention Rich Internet Applications (RIA) » Blog Archive » IDEA series (ix) selective actions -- Topsy.com said,
January 14, 2011 @ 2:22 am
[...] This post was mentioned on Twitter by Dierk König and lucastex_grails. lucastex_grails said: IDEA series (ix) selective actions http://goo.gl/fb/YJOvC [...]