Rename
Rename refactoring allows you to rename symbols, files, and directories globally with all the references to them in the code corrected automatically.
Rename a symbol
Select an item to be renamed.
Select
from the context menu or press Shift+F6. The selected symbol gets highlighted, and you can type a new name in the highlighted area.CLion displays and next to the highlighted element.
You can click these icons or press Tab to open the context menu and select the additional rename options.
Comments and strings: the occurrences of the symbol will be also renamed in comments and string literals.
Text occurrences (Objective-C) : the occurrences of the symbol will be also renamed in files that don't contain any source code (documentation, text files, HTML files, and so on).
If you want to change other refactoring options or preview the refactoring results, click the More options link or press Shift+F6. In the dialog that opens, you can select the refactoring scope and click Preview to preview the changes in a separate tool window before applying them.
Rename a file or directory
Select the file or directory in the Project tool window.
Press Shift+F6 or select
from the context menu.In the Rename dialog that opens, specify the new name.
Select the Search in comments and strings checkbox to let CLion apply changes to comments and strings.
Clear the Rename associated file checkbox if don't want CLion to rename the associated files with the same name.
Change the refactoring scope in the corresponding field if needed.
Click Preview to observe possible changes in Find Tool Window. Click Refactor to proceed.
CLion finds all the occurrences of the filename and changes them respectively.
Example
This example represents CMakelists.txt before and after applying Rename file to Calendar.cpp:
Before | After |
---|---|
cmake_minimum_required(VERSION 3.2)
project(Calendar_master)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES
calendars/Calendar.cpp
calendars/Calendar.h
main.cpp)
add_executable(Calendar_master ${SOURCE_FILES}
|
cmake_minimum_required(VERSION 3.2)
project(Calendar_master)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES
calendars/CalendarRen.cpp
calendars/CalendarRen.h
main.cpp)
add_executable(Calendar_master ${SOURCE_FILES})
|