PyCharm 2016.2 Help

Move Refactorings

On this page:

Move refactorings: basics

The Move refactorings allow you to move classes, functions, modules, files and directories within a project. So doing, PyCharm automatically corrects all references to the moved symbols in the source code.

The following Move refactorings are available:

  • The Move File refactoring moves a file to another directory.
  • The Move Directory refactoring moves a directory to another directory.
  • The Move Class/Function refactoring moves a Python class or function to another Python file.
  • The Move Module Members refactoring moves top-level symbols of a Python class.
  • The Move Static Member refactoring moves a static method, variable, or constant from one class to another.

Performing Move refactoring

To perform a Move refactoring, follow these general steps:

  1. Select the symbol to be moved and do one of the following:
    • On the Refactor menu, or on the context menu, choose Move.
    • Press F6.
    • In the Project tool window, drag the symbol to the new destination.

    The dialog that opens depends on the type of the selected symbol.

  2. Specify the move options according to the type of the item to be moved. See option descriptions in the Move dialog box reference.
  3. Preview and apply the changes.

Moving top-level symbols

To move a member, follow these steps:

  1. Place the caret at a top-level symbol, for example:
  2. Press F6. The dialog box Move Module Members opens:

    Refer to the dialog reference for the detailed description of controls.

  3. In this dialog box, select the members to be moved, and specify the target file.
  4. Preview and apply the changes.

See Also

Last modified: 23 November 2016