On this page:
- Adding lines
- Duplicating lines
- Deleting lines
- Moving lines
- Moving statements
- Moving code element left or right
- Press ⇧⏎ or ⇧⏎⇧⏎ or ⇧⏎⇧⏎ or ⇧⏎⇧ Enter, ⇧⏎ or ⇧⏎⇧ Enter, ⇧⏎ or ⇧⏎ to add a new line after the one where the
caret is currently located and move the caret to the beginning of this new line.
For instance, you have typed some text:

Press ⇧⏎ or ⇧⏎⇧⏎ or ⇧⏎⇧⏎ or ⇧⏎⇧ Enter, ⇧⏎ or ⇧⏎⇧ Enter, ⇧⏎ or ⇧⏎ to start the next line immediately:

- To add a line before the current one, press ⌥⌘⏎ or ⌥⌘⏎⌥⌘⏎ or ⌥⌘⏎⌥⌘⏎ or ⌥⌘⏎^ ⌥ Enter, ⌃⌥⏎ or ⌃⌥⏎^ ⌥ Enter, ⌃⌥⏎ or ⌃⌥⏎.
Make sure that keyboard shortcuts are not in conflict. You can do that in the Keymap page of the Settings/Preferences dialog.
- Place the caret at the line to be duplicated, or select the desired fragment of text.
- Press ⌘D or ⌘D⌘D or ⌘D^ D, ⌃D or ⌃D⌘ D, ⌘D or ⌘D.
- Place the caret at the line to be moved.
- Do one of the following:
- On the main menu, choose or .
- Press ⌥⇧↑ or ⌥⇧↑⌥⇧↑ or ⌥⇧↑⇧ ⌥ Up, ⌥⇧↑ or ⌥⇧↑⇧ ⌥ Up, ⌥⇧↑ or ⌥⇧↑ or ⌥⇧↓ or ⌥⇧↓⌥⇧↓ or ⌥⇧↓⇧ ⌥ Down, ⌥⇧↓ or ⌥⇧↓⇧ ⌥ Down, ⌥⇧↓ or ⌥⇧↓.
IntelliJ IDEA moves the selected line one line up or down, performing the syntax check. For example:

After moving line at caret:

- Select a statement to be moved, or just place the caret at the first or last lines of a multi-line statement. Note that if moving a statement is not allowed in the current context, the commands will be disabled.
- Do one of the following:
- On the main menu, choose .
- Press ⇧⌘↑ or ⇧⌘↑⇧⌘↑ or ⇧⌘↑⌥↑ or ⌥↑^ ⇧ Up, ⌃⇧↑ or ⌃⇧↑^ ⇧ Up, ⌃⇧↑ or ⌃⇧↑ or ⇧⌘↓ or ⇧⌘↓⇧⌘↓ or ⇧⌘↓⌥↓ or ⌥↓^ ⇧ Down, ⌃⇧↓ or ⌃⇧↓^ ⇧ Down, ⌃⇧↓ or ⌃⇧↓.
If you apply the same commands to a line at caret, or a to a selection, it will be moved one line up or down.
IntelliJ IDEA moves the selected statement above the previous one, or directly underneath the next one, performing the syntax check. For example, place the caret at the method declaration:

After moving the statement:

- Place the caret at the desired code element, or select the elements to be moved.
- Do one of the following:
- On the main menu, choose the commands or
- Press ⌥⇧⌘← or ⌥⇧⌘←⌥⇧⌘← or ⌥⇧⌘←⌥⇧⌘← or ⌥⇧⌘←^ ⇧ ⌥ Left, ⌃⌥⇧← or ⌃⌥⇧←^ ⇧ ⌥ Left, ⌃⌥⇧← or ⌃⌥⇧← or ⌥⇧⌘→ or ⌥⇧⌘→⌥⇧⌘→ or ⌥⇧⌘→⌥⇧⌘→ or ⌥⇧⌘→^ ⇧ ⌥ Right, ⌃⌥⇧→ or ⌃⌥⇧→^ ⇧ ⌥ Right, ⌃⌥⇧→ or ⌃⌥⇧→
Examples of code elements for which this functionality is currently implemented:
- Java: method invocation arguments, method declaration arguments,
enum constants, array initializer expressions.

You can propagate such a move in a method declaration to the method invocations - just immediately after move press ⌥⏎ or ⌥⏎⌥⏎ or ⌥⏎⌘1 or ⌘1⌥ Enter, ⌥⏎ or ⌥⏎⌥ Enter, ⌥⏎ or ⌥⏎, and choose the action Apply signature change:

- XML: tag attributes.

- HTML: tag attributes.
