IntelliJ IDEA 2020.3 Help

Groovy

The Groovy plugin is bundled with IntelliJ IDEA and enabled by default.

IntelliJ IDEA supports the latest stable version of Groovy and Groovy 3 syntax.

User interface

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 ).

User interface for Groovy

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 Escape.

Below is a list of shortcuts that invoke the tool windows you will most often need:

Tool WindowShortcut
ProjectAlt+1
Version ControlAlt+9
RunAlt+4
DebugAlt+5
TerminalAlt+F12
EditorEscape

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 Ctrl+Shift+F12. 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 Alt+Home.

Navigation bar

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.

Speed search

For more details, refer to Overview of the user interface, Editor basics, and Tool windows.

Editor basics

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:

ActionDescription
Move the current line of codeCtrl+Shift+Up Ctrl+Shift+Down
Duplicate a line of codeCtrl+D
Remove a line of codeCtrl+Y
Comment or uncomment a line of codeCtrl+/
Comment a block of codeCtrl+Shift+/
Find in the currently opened fileCtrl+F
Find and replace in the current fileCtrl+R
Next occurrenceF3
Previous occurrenceShift+F3
Navigate between opened tabsAlt+Right Alt+Left
Navigate back/forwardCtrl+Alt+Left Ctrl+Alt+Right
Expand or collapse a code block in the editorCtrl+NumPad + Ctrl+NumPad -
GenerateAlt+Insert
Surround withCtrl+Alt+T
Highlight usages of a symbolCtrl+F7

To expand a selection based on grammar, press Ctrl+W. To shrink it, press Ctrl+Shift+W.

IntelliJ IDEA can select more than one piece of code at a time. You can select next occurrence via Alt+J and deselect by pressing Alt+Shift+J. You can even select all occurrences at once, by pressing Ctrl+Alt+Shift+J.

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.

Groovy code style and formatting

IntelliJ IDEA automatically applies a code style you've configured in the Groovy code style settings as you edit.

Groovy code style settings

Check the following formatting shortcuts:

ActionShortcut
Reformat codeCtrl+Alt+L
Auto-indent linesCtrl+Alt+I
Optimize importsCtrl+Alt+O

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.

Last modified: 08 March 2021