CLion 2025.1 Help

Postfix completion

With postfix templates, you can transform an already-typed expression to a different one based on a postfix after the dot, the type of the expression, and its context. CLion includes a set of predefined postfix completion templates that you can use for other programming languages as well. You can copy, enable, and disable these templates.

Postfix templates in suggestion list

In CLion, postfix code completion is available for C/C++, Python, Rust, JavaScript, TypeScript, and SQL.

For C++, postfix completion can be especially useful for the cases of wrapping with a C++-style cast, make_shared/make_unique, various loops, and begin/end idioms.

Enable and configure postfix completion

  • In the Settings dialog (Ctrl+Alt+S), open Editor | General | Postfix Completion and select the Enable postfix completion checkbox.

  • Enable or disable postfix templates for the selected language.

    Postfix completion settings
  • Set the Tab, Space, or Enter key to expand postfix templates.

Transform a statement with a postfix

  1. Type an expression and then type a postfix after a dot. For example, type .if.

  2. Press Tab.

    void myfunc (int arg) { arg.if }
    void myfunc (int arg) { if (arg) }

    The initial expression gets wrapped with an if statement.

Postfix completion options are shown as part of the basic completion suggestion list. To see a full list of postfix completions applicable in the current context, press Ctrl+J.

Edit a postfix template name

You can edit the predefined postfix templates, for example, to replace a long key with a shorter one, or to expand the list of applicable expression types.

  1. Press Ctrl+Alt+S to open settings and then select Editor | General | Postfix Completion.

  2. Double-click a template name in the tree or click the icon above the list of templates and edit it as required.

    Editing a template name

Create custom postfix templates (JavaScript, TypeScript, SQL, Rust)

  1. Press Ctrl+Alt+S to open settings and then select Editor | General | Postfix Completion.

  2. Click the Add button (the Add button) on the toolbar.

  3. In the Create New Template dialog that opens, specify Key, a combination of symbols after the dot that will invoke the template.

  4. Select which expression types the new template will be applicable to, and type the target expression in the following format: $EXPR$ <target_expression>, for example, $EXPR$ =!null.

Share postfix templates

You can share postfix templates in the following ways:

Postfix vs. live templates

Postfix code completion is similar to live templates which allow you to create custom constructs to be used anywhere inside your code.

The difference is that live templates insert predefined code snippets, while postfix completion wraps or modifies existing expressions.

Last modified: 10 March 2025