Updated on 2026-07-29 GMT+08:00

Code Generation

CodeArts Agent can generate context-based code suggestions in the editor. Code generation can be triggered either automatically or through shortcut keys.

Introduction

The tool offers smart suggestions for single lines of code and can generate entire code blocks at once.

The tool smartly finishes the rest of the code on the current line, useful for basic tasks like assignments or one-line function calls.

The tool creates full code blocks with several lines at once, useful for handling multistep logic like building functions, loops, or conditional statements.

Automatic Code Generation

  • While typing, pause to allow the tool to analyze the context and provide code suggestions.
  • Press Enter to allow the tool to analyze the context and provide code suggestions.

Code Generation by Shortcut Keys

You can use shortcut keys to quickly activate the intelligent assistance function. CodeArts Agent automatically identifies the context and intelligently generates code snippets based on the code structure, variable types, and logical relationships.

Table 1 Shortcut keys

Shortcut Key

Description

Windows/Linux

Mac

Alt+X

Option(⌥)+X

Generate a code line.

Alt+C

Option(⌥)+C

Generate multiple code lines.

Tab

Tab

Accept the generated code.

Ctrl+Right

Command(⌘)+Right

Accept the generated code word by word.

Escape

Escape

Cancel the generated code.

Alt+R

Option(⌥)+R

Regenerate the code.

Alt+[

Option(⌥)+[

Go to the previous suggestion during code regeneration.

Alt+]

Option(⌥)+]

Go to the next suggestion during code regeneration.

Example: Completing a Function Body

  1. Log in to CodeArts Agent IDE as instructed in Quick Start.
  2. In the editor, move the cursor to the end of the following method that needs to be completed:

    /**
         * Create a new product.
         *
         * @param product Product object that contains product details.
         * @return Return ResponseEntity that contains the created product if the product is created successfully.
         *         Return ResponseEntity that contains the error information if an exception occurs.
         */
        @PostMapping
        public Class ResponseEntity<?> createProduct(@RequestBody Product product) {
    }

  3. Press Enter. CodeArts Agent will automatically complete the function body.

    You can accept or reject the generated code suggestion. If the initial generation is incomplete, press Tab to accept what exists and then press Alt+C (Windows/Linux) or Option (⌥)+C (macOS) to continue the generation. Repeat this action until the code block is fully fleshed out.

    Figure 1 Code generation