1
votes

Is there any intellij idea shortcut to select a token in a statement?

For example, consider this:

cell.setCellValue((profileInfo.get("startTimeOfCrawl")!=null)?profileInfo.get("startTimeOfCrawl"):"");

Currently, if my cursor is on the first character of the above statement(i.e. at beginning of c of cell, if I have to select profileInfo, then I will have to use my mouse and double click on profileInfo to select that.

Another workaround I found was to use arrow keys to get cursor to profileInfo Then use ctrl+shift+right-arrow keys to select till the end(i.e. till o) of profileInfo This is good when my cursor is placed at beginning of profileInfo(or even end in which case we can use left-arrow key). But if my cursor is placed somewhere in between of profileInfo then I will have to use ctrl+right (or ctrl+left) to get the cursor to either beginning or end of this token. Then I Will have to use ctrl+shift+right-arrow (or left-arrow as the case may be).

(Switching from keyboard to mouse breaks the continuity, hence looking for keyboard shortcuts.)

Is there a better shortcut to do above in 1 step?

PS: Solution to above will be very useful when making string replacements.

2

2 Answers

1
votes

Use Edit | Extend Selection (Ctrl-W in the default keymaps, Alt-Up in the Mac OS 10.5+ keymap). You can press it multiple times to extend the selection to larger enclosing syntax constructs.

0
votes

I can't think of a 1-step process of doing this but try using the alt to traverse via arrow keys, it will traverse it per "word" instead of per character.

You can also use alt+shift+ arrow keys to select per word.