Code generation
and refactorings

Create from usage

In CLion you can use a function, variable, data member or even a class before it is declared. The IDE will highlight it in red and suggest a quick-fix. Press Alt+Enter to add the appropriate declaration. For functions, CLion also detects the return type and the types of its parameters.

Intention actions

Intentions help you apply automated changes to code that is correct, to improve it or to make your coding routine easier. Add data member and initializers to a constructor, apply De Morgan’s laws to a logical expression, introduce typedef, move a definition out of a class, and much more. The light bulb in the left-hand editor gutter indicates one or more intention actions are available; simply press Alt+Enter to apply one.

'Surround with' and Live Templates

Use live templates (choose Code | Insert Live Template or press Ctrl+J ) to produce entire code constructs. All ready-to-use Live Templates are listed in settings (Editor | Live Templates). You can extend and customize this set of templates as needed. To apply a Live Template in code, simply type its abbreviation and press Tab. Then, use Enter or Tab to navigate through the template variables.

Consider also 'Surround with' templates, to quickly surround your code with complete constructs. Choose Code | Surround With or press Ctrl+Alt+T in order to easily generate if, while, for, #ifdef, or other wrappers, depending on the context.

Generate menu

Saving time on typing is really easy with CLion's Generate menu Alt+Insert.

Get setters/getters, constructors/destructors, equality, relational and stream output operators in one click. Select fields to use during the generation, as well as various options like generate as class members, generate in-place, use std::tie for the operators implementation and other options as necessary.

In case some of the operators are already there, CLion suggests you to add missing ones or complete replace all the existing.

Implement, override or generate definitions

Feel the power of the code generation with Implement functions (Ctrl+I), Override functions (Ctrl+O) and Generate Definitions (Shift+Ctrl+D).

Generate in-place setting default value depends on your code as CLion adapts to the patterns you are using in your project, heuristics are implemented to support the most common cases (like header-only or cpp-only classes, and others).


CLion helps you keep your code high-quality, by providing a set of reliable refactorings. When you refactor, it applies your code changes throughout the scope — safely.

To see all refactorings available at the current location, use the Refactor This... menu (press Ctrl+Alt+Shift+T ):

The list of refactorings includes:

Rename Shift+F6, that renames symbols, automatically correcting all references in the code for you.

Change Signature Ctrl+F6 helps you add/remove/reorder function parameters, change the result type or update the name of the function, all usages will be fixed as well.

Inline Ctrl+Alt+N replaces redundant variable usage/function calls with its initializer/declaration.

Extract (Function Ctrl+Alt+M, Typedef Ctrl+Alt+K, Variable Ctrl+Alt+V, Parameter Ctrl+Alt+P, Define Ctrl+Alt+D, Constant Ctrl+Alt+C) — here, CLion analyzes the block of code where you invoke the refactoring, detects the input and output variables and the usages of the selected expression, to replace them with a newly created entity of your choice.

Pull Members Up/Down safely moves class members to a base class/subclass.

And more.

Watch demo