CLion 2022.3 Help

Move and Copy

Move refactorings allow you to move files, directories, static class members and declarations within a project. CLion tracks these movements and automatically corrects all references to the moved symbols in the source code.

Move a file or directory to another directory

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

  2. Do one of the following:

    • Press F6.

    • Right-click the selection and select Refactor | Move.

    • Call Refactor | Move from the main menu.

  3. In the To directory field, specify the destination folder. Choose an existing folder from the list or type the full path to the parent folder to be created.

  4. Select the Search for references checkbox to have all references updated automatically.

Move static class members to another class

  1. Place the caret inside the class from which you want to move a static member or select it in the Structure View view.

  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.

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

    the Move Static 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. Place the caret in the declaration that you want to move or select it in the Structure View view.

  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

  3. Select the destination file. If required, you can also specify the destination namespace, existing or new.

    Dependent declarations are highlighted with blue.

    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 file or directory with its entire structure from one directory to another.

Copy a 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: 30 November 2022