# Code generation

> **TL;DR**
> `Code | Generate` or `Alt+Insert` (Windows), `⌘ N` (macOS), `⌃ N` (IntelliJ IDEA Classic (macOS)), `⌘ N` (macOS System Shortcuts), `Alt+Insert` (XWin), `Alt+Insert` (GNOME), `Alt+Insert` (KDE), `Alt+Insert` (Emacs), `Alt+Insert` (Sublime Text), `⌘ N` (Sublime Text (macOS)), `⌘ N` (Xcode), `Alt+Insert` (Visual Studio), `⌘ ⌃ N` (Visual Studio (macOS)), `Alt+Insert` (ReSharper), `⌘ ⌃ N` (ReSharper (macOS)), `Alt+Insert` (QtCreator), `Alt+Insert` (QtCreator (macOS)), `Alt+Insert` (NetBeans), `Alt+Insert` (Eclipse), `⌘ N` (Eclipse (macOS))
>
>
>
> Configure: `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `⌘ Comma` (Xcode), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (ReSharper), `⌘ Comma` (ReSharper (macOS)), `Ctrl+Alt+S` (QtCreator), `⌘ Comma` (QtCreator (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS)) `Settings | Editor | File and Code Templates`

CLion provides multiple ways to generate common code constructs and recurring elements, which helps you increase productivity. These can be either [file templates](using-file-and-code-templates.html) used when creating a new file, custom or predefined [live templates](using-live-templates.html) that are applied differently based on the context, various wrappers, or automatic pairing of characters.

The Generate menu helps you quickly create standard code constructs in your code. Depending on the current context, the caret position, or selected code, CLion gives you a list of constructs to be generated.

![the Generate menu](https://resources.jetbrains.com/help/img/idea/2026.2/cl_generatemenu_2.png)

Procedure: Invoke the Generate popup

Use one of the following options:

* Press `Alt+Insert` (Windows), `⌘ N` (macOS), `⌃ N` (IntelliJ IDEA Classic (macOS)), `⌘ N` (macOS System Shortcuts), `Alt+Insert` (XWin), `Alt+Insert` (GNOME), `Alt+Insert` (KDE), `Alt+Insert` (Emacs), `Alt+Insert` (Sublime Text), `⌘ N` (Sublime Text (macOS)), `⌘ N` (Xcode), `Alt+Insert` (Visual Studio), `⌘ ⌃ N` (Visual Studio (macOS)), `Alt+Insert` (ReSharper), `⌘ ⌃ N` (ReSharper (macOS)), `Alt+Insert` (QtCreator), `Alt+Insert` (QtCreator (macOS)), `Alt+Insert` (NetBeans), `Alt+Insert` (Eclipse), `⌘ N` (Eclipse (macOS)).

* Call `Code | Generate` from the main menu.

* Right-click in the editor and choose Generate from the context menu.

Procedure: Generate constructors

1. Select Constructor from the Generate popup.

2. If the class contains fields, select the fields to be initialized:

![Generate constructor](https://resources.jetbrains.com/help/img/idea/2026.2/cl_generateconstructor_dialog.png)

3. If the Generate in-place checkbox is selected, the template constructor will be generated in the `public` area of the class, otherwise the code will be placed in the corresponding `cpp` file.

![Constructor generated in-place](https://resources.jetbrains.com/help/img/idea/2026.2/cl_generateconstructor_result.png)

Procedure: Generate getters and setters

1. Select Getter, Setter, or Getter and Setter from the Generate popup.

2. Select the fields to generate the getters/setters for:

![Generate getters and setters](https://resources.jetbrains.com/help/img/idea/2026.2/cl_generategettersetter_dialog.png)

3. If the Generate in-place checkbox is selected, the getters/setters will be generated in the `public` area of the class, otherwise the code will be placed in the corresponding `cpp` file.

![Getters and setters generated in-place](https://resources.jetbrains.com/help/img/idea/2026.2/cl_generategettersetter_results.png)

Procedure: Generate equality operators

This action generates `operator==` and `operator!=` functions that will use the selected fields to compare objects of the current class.

1. Select Equality Operators from the Generate popup.

2. Select the fields to be used and set addition options:

![Generate equality operators](https://resources.jetbrains.com/help/img/idea/2026.2/cl_generateoperators_equality_dialog.png)

3. If the Generate in-place checkbox is selected, the operator functions will be generated in the `public` area of the class, otherwise the code will be placed in the corresponding `cpp` file.

![Equality operators generated in-place](https://resources.jetbrains.com/help/img/idea/2026.2/cl_generateoperators_equality_result.png)

Procedure: Generate relational operators

This action generates `operator<`, `operator>`, `operator<=`, and `operator>=` functions that will use the selected fields to compare objects of the current class.

1. Select Relational Operators from the Generate popup.

2. Select the fields to be used and set addition options:

![Generate relational operators](https://resources.jetbrains.com/help/img/idea/2026.2/cl_generateoperators_relational_dialog.png)

3. If the Generate in-place checkbox is selected, the operator functions will be generated in the `public` area of the class, otherwise the code will be placed in the corresponding `cpp` file.

![Relational operators generated in-place](https://resources.jetbrains.com/help/img/idea/2026.2/cl_generateoperators_relational_result.png)

Procedure: Generate stream output operators

This action generates the insertion operator `operator<<` that will use the selected fields to define how to generate stream output for objects of the current class.

1. Select Stream Output Operator from the Generate popup. Select the fields to be used.

2. If the Generate in-place checkbox is selected, the operator function will be generated in the `public` area of the class, otherwise the code will be placed in the corresponding `cpp` file.

![Stream output operator generated in-place](https://resources.jetbrains.com/help/img/idea/2026.2/cl_generateoperators_streamoutput_result.png)

