WebStorm 2016.3 Help

Adding, Deleting and Moving Code Elements

On this page:

To add a line

  • Press Shift+Enter 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:

    /help/img/idea/2016.3/wi_shiftEnter1.png

    Press Shift+Enter to start the next line immediately:

    /help/img/idea/2016.3/wi_shiftEnter2.png
  • To add a line before the current one, press Ctrl+Alt+Enter.

To duplicate a line or fragment

  1. Place the caret at the line to be duplicated, or select the desired fragment of text.
  2. Press Ctrl+D.

To remove a line

  • Press Ctrl+Y to delete the line at caret.

To move a line

  1. Place the caret at the line to be moved.
  2. Do one of the following:
    • On the main menu, choose Code | Move Line Up or Code | Move Line Down.
    • Press Shift+Alt+Up or Shift+Alt+Down.

    WebStorm moves the selected line one line up or down, performing the syntax check. For example:

    wi_moveline1.png

    After moving line at caret:

    wi_moveline2.png

To move a statement up or down

  1. 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.
  2. Do one of the following:
    • On the main menu, choose Code | Move Statement Up/Move Statement Down.
    • Press Ctrl+Shift+Up or Ctrl+Shift+Down.

    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.

    WebStorm 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:

    wi_moveStatement1.png

    After moving the statement:

    wi_moveStatement2.png

To move code element to the left or to the right

  1. Place the caret at the desired code element, or select the elements to be moved.
  2. Do one of the following:
    • On the main menu, choose the commands Code | Move Element Left or Code | Move Element Right
    • Press Ctrl+Shift+Alt+Left or Ctrl+Shift+Alt+Right

Examples of code elements for which this functionality is currently implemented:

  • XML: tag attributes.
    /help/img/idea/2016.3/move_element1.png
  • HTML: tag attributes.
    /help/img/idea/2016.3/move_element3.png

See Also

Last modified: 1 December 2016