CLion 2023.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. Make sure that indexing is fihished. Otherwise, CLion will warn you about the potential problems:

    Move while indexing is unfinished
  3. Do one of the following:

    • Drag the file or folder to the new location.

    • Press F6.

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

    • Call Refactor | Move from the main menu.

  4. CLion will check for the related files and suggest moving them as well:

    Moving related files
  5. Specify the following in the Move dialog:

    • In the To directory field, specify the destination folder. Choose an existing folder from the list or type the full path.

    • Set the Search for references checkbox to have all references updated automatically.

    The Move dialog
  6. Click Refactor when ready.

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.

  2. Do one of the following:

    • Press F6.

    • Call Refactor | Move.

    • From the context menu, select Refactor | Move.

  3. In the Move Static Members dialog, select the static members to be moved and specify the destination class, existing or new.

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

    In case of conflicts, when there are members dependent on the one you move, they will be shown in a 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.

  2. Do one of the following:

    • Press F6

    • Call Refactor | Move.

    • From the context menu, select Refactor | Move.

  3. Specify the following in the Move Declarations dialog:

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

    • Select the members to be moved.

    the Move Declaration dialog

    Dependent declarations are marked with the warning icon:

    Warning on dependent members
  4. Click Move to proceed or Preview to check the results before the actual refactoring.

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.

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

Last modified: 23 February 2024