In this section:

Basics

The basic way to select a piece of text is to extend the selection with the mouse cursor. IntelliJ IDEA, as a keyboard-centric IDE, suggests to use navigation keys to make selections.

You can opt to select pieces of text, or select rectangular fragments in the column mode, extend and shrink the selection, use multiselection, and sticky selection.

Selecting all text in the active editor tab

To select the entire text in the current editor tab, do one of the following:

  • On the main menu, choose Edit | Select All.
  • Press ⌘A⌘A⌘A⌃A⌃X, H.

Selecting with navigation keys

To select text from the current caret position to the beginning/end of the current word:

  • ⌥⇧←⌥⇧←⌥⇧←⌃⇧←⌃⇧←, ⌥⇧→⌥⇧→⌥⇧→⌃⇧→⌃⇧→.

To select text from the caret position to the beginning/end of the current line:

  • Double-click ^ and press Home/End

To select text from the current caret position to the top/bottom of the screen:

  • ⇧⌘⇞⇧⌘⇞⇧⌘⇞⌃⇧⇞⌃⇧⇞, ⇧⌘⇟⇧⌘⇟⇧⌘⇟⌃⇧⇟⌃⇧⇟.

Alternative ways to select code

To make selection of a column of text, do one of the following:

  • Keeping the key pressed, drag your mouse pointer to select the desired area.
  • Keeping the middle mouse button pressed, drag your mouse pointer to select the desired area.
  • Press ⇧ ⌥ and the middle mouse button. This is specially helpful, if you want to avoid dragging.

Extending selection

To extend selection from the word at caret to the piece of code the caret is contained in, do one of the following:

  • On the main menu, choose Edit | Extend Selection
  • Press ⌥↑⌘W⌃⇧↑⌃W⌃⌥W to select the word where the caret is currently located.
  • Press ⌥↑⌘W⌃⇧↑⌃W⌃⌥W successively to extend selection to the next containing node (for example, an expression, a paired tag, an entire conditional block, a method body, a class, a group of vararg arguments, etc.)

    While extending selection, keep in mind that:

    • Pressing ⌥↑⌘W⌃⇧↑⌃W⌃⌥W successively in plain text or comments extends the selection first to the current sentence, then to the current paragraph.
    • Pressing ⌥↑⌘W⌃⇧↑⌃W⌃⌥W successively in a method call that contains vararg arguments, first selects a vararg argument the caret rests at, then the whole group of vararg arguments, and then all arguments in the method call.

Shrinking selection

To shrink selection in the reverse order (from the outermost container to the word where the caret currently resides), do one of the following:

  • On the main menu, choose Edit | Shrink Selection
  • Press ⌥↓⇧⌘W⌃⇧↓⌃⇧W⌃⇧W.

    The selection extends or shrinks according to capitalization, if the Use "CamelHumps" words check box is selected on the Smart Keys page of the editor settings.

    If you want to make selection according to capitalization, using double-click, make sure that the check box Honor CamelHumps words... is selected on the General page of the editor settings.

Multiselection

IntelliJ IDEA supports selecting multiple text fragments. So doing, one can select multiple words, lines or rectangles.

To select multiple words, follow these steps
  1. Do one of the following:
    • Press ⇧ ⌥ and double-click the left mouse button.

      ../../Shared/multiselection1.png

    • Press ⌃G⌃G⌃G⌥J⌥J, or select some text fragment. Then press ⌃G⌃G⌃G⌥J⌥J again, to find the matching piece of text.
  2. After selection is complete, you can start editing all the fragments as if they were one.
To select multiple fragments of text, follow these steps
  1. Press ⇧ ⌥
  2. Drag the mouse pointer

../../Shared/multiselection2.png

To select multiple rectangular fragments of text, follow these steps
  1. Press ^ ⇧ ⌥ (Windows or UNIX)/ ⇧ ⌥ Cmd(macOS)
  2. Drag the mouse pointer

../../Shared/multiselection3.png

Refer to the section Multicursor for additional information.

Toggling between line and column selection modes

To toggle between the line and the column selection modes, do one of the following:

  • On the main menu, choose Edit | Column Selection Mode.
  • On the context menu of the editor, choose Column Selection Mode.
  • Press ⇧⌘8⇧⌘8⇧⌘8.

Sticky selection

To toggle sticky selection, press ⇧⌘A⇧⌘A⌘3⌃⇧A⌃⇧A, in the pop-up frame type sticky, and choose Toggle Sticky Selection from the suggestion list:

../../Shared/sticky_selection.png

In the Emacs keymap, use keyboard shortcut ⌃Space.

Tips and tricks

  • When sticky selection is on, you can turn it off by invoking copy or cut, or by toggling it again.
  • To create a large rectangular selection, create a normal selection first, with the given starting and ending points, and then press ⇧⌘8⇧⌘8⇧⌘8 to toggle to the column selection mode.