CLion 2020.1 Help

Move Refactorings

The Move refactorings allow you to move files, directories, class members and declarations within a project. In doing so, CLion tracks these movements and 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 Member refactoring moves the selected class member to a new or an existing class.

  • The Move Declaration refactoring moves the top level type declaration to a new or an existing file.

Move a file or directory to another directory

  1. Select the file or directory in the Project tool window.

  2. In the To directory field, specify the folder to move the selected file or folder to. Choose an existing folder from the list or type the full path to the parent folder to be created.

  3. To have the references to the selected file or folder updated according to the refactoring result, select the Search for references checkbox.

Move class members to another class

  1. In the Editor or Structure view, select the class member to be moved.

  2. Do one of the following:

    • From the main menu, choose Refactor | Move.

    • From the context menu of the selection, choose Refactor | Move.

    • Press F6.

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

  3. Select the class members to be moved and specify the destination class name, existing or new.

    the Move Members dialog
  4. Click Move to proceed or Preview to check the results before the actual refactoring.

    In case of conflicts, when there are members dependent on the one you move, they will be shown in the separate dialog.

Move declarations to another file or namespace

  1. In the editor or Structure view, select the declaration to be moved to another file.

  2. Do one of the following:

    • From the main menu, choose Refactor | Move.

    • From the context menu of the selection, choose Refactor | Move

    • Press F6

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

  3. Select the declarations to be moved. Specify the destination file or namespace, existing or new:

    the Move Declaration dialog
  4. Click Move to proceed or Preview to check the results before the actual refactoring.

    In case of conflicts, when there are members dependent on the one you move, they will be shown in the separate dialog.

Copy refactoring

The Copy refactoring allows you to copy a class, file, or directory with its entire structure from one directory to another.

Copy a class, file, or directory

  1. Select the desired item in one of the views or open it in the editor.

  2. Do one of the following:

    • From the main menu or the selection context menu, choose Refactor | Copy.

    • Press F5.

    • Select the desired class in the Project tool window and drag it to the target destination with Ctrl pressed.

  3. In the that opens specify the new name and destination, then click OK.

Last modified: 21 July 2020