Create template-based files
CLion provides file templates for most of the supported languages. These templates help you create files with initial content already present. For example, there are three templates for C/C++: C++ Class, C++ Source File, C++ Header File.
Create a new C++ class
In the Project tool window, select the directory in which you want to add new files. Right-click it and select from the context menu.
In the dialog that opens:
Specify the name of a class.
From the list, choose the type of the source and header files for the new class, if you want to change the default type which is defined in the New File Extensions tab of the Code Style C/C++ dialog.
Select the Create header only checkbox if you want to create the header file only.
- Select the Add to targets checkbox to add the created files to the list of the source files for the selected target(s).
Select the desired target from the list. In the below pane, see the CMakeLists.txt variable where CLion suggests to add the created files.
Create a new C/C++ source file
In the Project tool window, select the directory in which you want to add new files. Right-click it and select from the context menu.
In the dialog that opens:
Specify the name of a file.
From the list, select the source file type, if you want to change the default type which is defined in the New File Extensions tab of the Code Style C/C++ dialog.
Select the Create an associated header checkbox if you want to create the respected header file as well.
- Select the Add to targets checkbox to add the created file to the list of the source files for the selected target(s).
Select the desired target from the list. In the below pane, see the CMakeLists.txt variable where CLion suggests to add the created file.
Create a new C/C++ header
In the Project tool window, select the directory in which you want to add new files. Right-click it and select from the context menu.
In the dialog that opens:
Specify the name of a file.
From the list, select the header file type, if you want to change the default type which is defined in the New File Extensions tab of the Code Style C/C++ dialog.
- Select the Add to targets checkbox to add the created file to the list of the source files for the selected target(s).
Select the desired target from the list. In the below pane, see the CMakeLists.txt variable where CLion suggests to add the created file.