CLion 2019.1 Help

Move and Copy

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. Do one of the following:
    • From the main menu, choose Refactor | Move File.

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

    • Press F6.

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

  3. 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.

  4. 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, existing or new

  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. Type the destination class name or click the browseButton button to choose.

  4. Select the class members to be moved to the specified class.

    cl moveMembersDialog

Move declarations to another file, existing or new

  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. Type the destination filename or click the browseButton button to choose.

  4. Select the declaration to be moved to another file.

    cl moveDeclarationDialog

Copy refactoring

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

To 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 Copy dialog that opens specify the new name and destination, then click OK.

Last modified: 2 July 2019

See Also

External Links: