|While developing in IntellIJ IDEA you will spend a bulk of your time working in the editor. That’s why it is worth knowing its basic features.|
The editor highlights matching brackets, scope, vertical indent guides and usages of the element at the caret by default. You can change this and more in Settings → Editor and Settings → Editor → Appearance.
Two other options worth mentioning are:
- Allow placement of caret after end of line, enabled by default. If you find this option annoying, you can disable it in the settings.
- Show line numbers; disabled by default.
One of the greatest editor features that new users find unusual and later brilliant is how it saves changes. IntelliJ IDEA does it automatically so you don’t need to worry about it. If you decide to roll-back some of your changes, you can always do it by using Local History.
On the status bar you can find useful information for the currently opened file, such as type of line endings (Windows/Unix), the encoding, the current branch in version control and the read-only status.
One more useful option (disabled by default) is showing method separators.
A definite must-know to be even more productive. Structural selection allows you to select expressions based on grammar. By pressing Ctrl + W (Cmd + W for Mac) you keep expanding your selection (starting from the caret). And vice versa, you can shrink it by pressing Shift + Ctrl + W (Shift + Cmd + W for Mac).
Column selection with mouse is available when you hold Alt. If you decide to use column selection by default, you can enable it via Edit → Column Selection Mode.
Another neat feature of the editor is folding. You can fold and unfold fragments of code by pressing Ctrl + . (Cmd + . for Mac).
- Move the current line of code (or selected block) via Shift + Ctrl + Arrows (Shift + Cmd + Arrows for Mac).
- Duplicate a line of code (or selected block) via Ctrl + D (Cmd + D for Mac)
- Remove a line of code (or selected block) via Ctrl + Y (Cmd + Y for Mac)
- Comment or uncomment a line of code (or selected block) via Ctrl + / (Cmd + / for Mac) and Shift + Ctrl + / (block comment for selected code).
- Optimize imports via Ctrl + O (Cmd + O for Mac).
- Find in the currently opened file via Alt + F3 (F3 to the next match rance and Shift + F3 to the previous match). Or, replace in the currently opened file via Ctrl + R (Cmd + R for Mac).
- Enable/show soft-wraps, disabled by default.
- Paste from stack via Shift + Ctrl + V (Shift + Cmd + V for Mac).
- Navigate between opened tabs via Alt + Arrows (Ctrl + Arrows for Mac).