Multiple carets and selections
When you type, edit, copy, or paste code, you can use multiple carets to perform these actions simultaneously on different lines. For example, you can add comment markers to multiple lines, or remove some characters in several occurrences of a word.
Add multiple carets
There are several ways in which you can add multiple carets:
Press and hold Shift+Alt and click at the next caret location.
You can press Ctrl twice and then, without releasing it, press the Up or Down arrow keys.
Press Shift+Alt and drag the caret to also select multiple words or text ranges.
After you set multiple carets, you can use the Alt+↑/↓ shortcut to move them back and forth. By default, the caret is moved to the end of the current word. However, you can change the caret's behavior.
Configure the caret behavior
In the Settings/Preferences dialog Ctrl+Alt+S, go to .
- In the Caret Movement section, select an appropriate behavior from the list.
For more information on the available settings options, refer to the General Settings.
Remove multiple carets
You can remove all of the carets with one action or one caret at a time.
Press Escape to delete all added carets.
Press Shift+Alt and click carets that you want to remove.
Enable the column selection mode
You can make a multiple selection of code in columns enabling a column selection mode. This mode is helpful when you want to edit several lines of code simultaneously.
- In the editor, press Alt+Shift+Insert to enable the column selection mode. Alternatively, right-click anywhere in the editor to open the context menu and select Column Selection Mode.
Place the caret at a symbol you need and either drag it up or down, or select a block of code and press the specified shortcut to achieve the same result.
Multi selection in occurrences of code
You can quickly locate all occurrences of the selected element in a file, make a multiple selection, or select the next or the previous occurrences.
Make a multiple selection of occurrences
- Place the caret at the needed element, then press Alt+J. Press the same key to find the next occurrence.
Alternatively, keeping Shift+Alt pressed, double-click or drag over the text you want to add to the selection.
Press Ctrl+Alt+Shift+J to select all occurrences in the file,.
Move the caret to the next or the previous occurrence
- Press F3 to move the caret to the next occurrence.
When you press F3, IntelliJ IDEA automatically removes the selection of the current occurrence and selects the next one.
- Press Shift+F3 to move the caret to the previous occurrence.
IntelliJ IDEA selects all the previous occurrences.
To find the next or the previous occurrence of the selected identifier, press Alt+Wheel up or Alt+Wheel down.