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 File / Directory - moves files/directories to another directory.
Move Static Member - moves static class members to a new or an existing class.
Move Declaration - moves top-level declarations to a new or an existing file.
Move a file or directory to another directory
Select the required file or directory in the Project tool window.
Make sure that indexing is fihished. Otherwise, CLion will warn you about the potential problems:
Do one of the following:
Drag the file or folder to the new location.
Press F6.
Right-click the selection and select
.Call
from the main menu.
CLion will check for the related files and suggest moving them as well:
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.
Click Refactor when ready.
Move static class members to another class
Place the caret inside the class from which you want to move a static member or select it in the Structure view.
Do one of the following:
Press F6.
Call
.From the context menu, select
.
In the Move Static Members dialog, select the static members to be moved and specify the destination class, existing or new.
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
Place the caret in the declaration that you want to move or select it in the Structure view.
Do one of the following:
Press F6
Call
.From the context menu, select
.
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.
Dependent declarations are marked with the warning icon:
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
Select the desired item in one of the views or open it in the editor.
Do one of the following:
From the main menu or the selection context menu, choose
.Press F5.
In the that opens specify the new name and destination, then click OK.