In this section:

  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.

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

    py_moveStatement1

    After moving the statement:

    py_moveStatement2

Make sure that keyboard shortcuts are not in conflict. You can do that in the Keymap page of the IDE Settings.

See Also

Procedures:

Reference:

Web Resources: