Move Refactorings
On this page:
- Move Refactorings: Basics
- Moving a File or a Directory to Another Directory
- Moving a class member to another class, existing or new:
- Moving a Declaration
- Moving a declaration or member that influence the others
Move Refactorings: Basics
The Move refactorings allow you to move files, directories, class members and declarations within a project. 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
Moving a File or a Directory to Another Directory
To move a file or directory to another directory, follow these steps:
- Select the file or directory in the Project tool window.
-
Do one of the following:
- On the main menu, choose , and then choose .
- On the context menu of the selection, choose , and then choose .
- Press F6.
The dialog that opens depends on the type of the selected symbol.
- In the To directory field, specify the folder to move the selected file or folder to. Choose an existing folder from the drop-down list or type the full path to the parent folder to be created.
- To have the references to the selected file or folder updated according to the refactoring result, select the Search for references check box.
Moving a class member to another class, existing or new:
To move a class member to the new class, follow these steps:
- In the Editor or Structure view, select the class member to be moved
- Do one of the following:
-
Type the destination class name or click the
button to choose.
-
Select the class members to be moved to the specified class.
Moving a Declaration
To move a top level declaration to another file, follow this steps:
- In the editor or Structure view, select the declaration to be moved to another file.
- Do one of the following:
-
Type the destination file name or click the
button to choose.
-
Select the declaration to be moved to another file.
Moving a declaration or member that influence the others
Let's consider the following sample of code:
d3
here depends on variable
d1
. If you apply Move Declaration refactoring to the above class and try to select
declaration of classSubCLass
to be moved, and leave declaration of d1
at the initial position,
CLion warns you about dependency:

d1
is highlighted with blue.
The same rules are applicable to Move Members refactoring.
See Also
External Links:
Last modified: 20 July 2016