Rename refactorings
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 the item to be renamed.
To select a file, click the desired file in the Project tool window.
To select a symbol in the editor, place the caret at the name of the symbol to be renamed.
To select a symbol in the Project tool window, make sure that the members are shown, and then click the desired symbol.
To select a symbol in the Structure view, click the desired symbol in the Structure tool window Alt+7.
Choose
from the main menu or from the context menu or press Shift+F6.If the Enable in-place mode checkbox in is set, the suggested names appear right below the symbol. You can choose between the suggestions, or type a new name.
If the In the modal dialogs refactoring option is selected on the Code Editing page of the Settings/Preferences dialog Ctrl+Alt+S, then the Rename dialog will pop up. In this dialog, you can specify additional settings and preview the changes:
Rename a file or directory
Select a desired file in the Project tool window.
Choose
on the main or context menu or press Shift+F6.In the Rename dialog that opens, specify the new filename. Select Search in comments and strings checkbox to let CLion apply changes to comments and strings.
Press Preview to observe possible changes in Find Tool Window. Press 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})
|