Groovy
The Groovy plugin is bundled with IntelliJ IDEA and enabled by default.
IntelliJ IDEA supports the latest stable version of Groovy and Groovy 4 syntax.
The user interface for Groovy looks similar to a regular one. However, it includes the Groovy console that you can open from the main menu (Tools | Groovy Console).
The most interesting part of the user interface is the IntelliJ IDEA Editor since it lets you invoke almost any IDE feature without leaving it, which helps you organize a layout where you have more screen space because auxiliary controls like toolbars and windows are hidden.
Accessing a tool window via its shortcut moves the input focus to it, so you can use all keyboard commands in its context. When you need to go back to the editor, press Esc.
Below is a list of shortcuts that invoke the tool windows you will most often need:
Tool Window | Shortcut |
---|---|
Project | Alt01 |
Version Control | Alt09 |
Run | Alt04 |
Debug | Alt05 |
Terminal | AltF12 |
Editor | Esc |
When you want to focus on the code, try the Distraction Free Mode. It removes all toolbars, tool windows, and editor tabs. To switch to this mode, on the main menu select View | Appearance | Enter Distraction Free Mode.
An alternative to the Distraction Free Mode may be hiding all tool windows by pressing CtrlShiftF12. You can restore the layout to its default by pressing this shortcut once again.
The Navigation Bar is a compact alternative to the Project tool window. To access the Navigation Bar, press AltHome.
Most components in IntelliJ IDEA (both tool windows and popups) provide speed search. This feature allows you to filter a list, or navigate to a particular item by using a search query.
tip
When you don't know the shortcut for an action, try using the Find action feature by pressing CtrlShift0A. Start typing to find an action by its name, see its shortcut or call it.
For more details, refer to User interface, Editor basics, and Tool windows.
A work in the editor is standard for Groovy as for any other languages with all the shortcuts offered by IntelliJ IDEA.
Check the following most useful editor shortcuts:
Action | Description |
---|---|
Move the current line of code | CtrlShift0↑ CtrlShift0↓ |
Duplicate a line of code | Ctrl0D |
Remove a line of code | Ctrl0Y |
Comment or uncomment a line of code | Ctrl0/ |
Comment a block of code | CtrlShift0/ |
Find in the currently opened file | Ctrl0F |
Find and replace in the current file | Ctrl0R |
Next occurrence | F3 |
Previous occurrence | ShiftF3 |
Navigate between opened tabs | Alt0→ Alt0← |
Navigate back/forward | CtrlAlt0← CtrlAlt0→ |
Expand or collapse a code block in the editor | NumPad + NumPad - |
Generate | AltInsert |
Surround with | CtrlAlt0T |
Highlight usages of a symbol | CtrlF7 |
To expand a selection based on grammar, press Ctrl0W. To shrink it, press CtrlShift0W.
IntelliJ IDEA can select more than one piece of code at a time. You can select next occurrence via Alt0J and deselect by pressing AltShift0J. You can even select all occurrences at once, by pressing CtrlAltShift0J.
For more details, refer to Editor basics.
With IntelliJ IDEA you don't need to save code changes every time since you can undo refactorings and revert changes from Local History.
IntelliJ IDEA automatically applies a code style you've configured in the Groovy code style settings as you edit.
Check the following formatting shortcuts:
Action | Shortcut |
---|---|
Reformat code | CtrlAlt0L |
Auto-indent lines | CtrlAlt0I |
Optimize imports | CtrlAlt0O |
Note that by default, IntelliJ IDEA uses regular spaces for indents instead of tabs. If you have files with lots of indents, you may want to optimize their size by enabling the Use tab character option located in Settings | Editor | Code Style | Groovy.
For more details, refer to Reformatting Source Code.
Thanks for your feedback!