AI capabilities 
Trae Plugin supports auto code completion, code generation, code editing, and more. You can use them to improve your programming efficiency.
Prerequisite 
Launch the side chat box using the keyboard shortcut (Windows: Ctrl + U; macOS: Command + U).
Code completion 
Trae AI can comprehend the current code and automatically suggest the rest of the code to make it complete.
Method 1: Press the Enter key to start a new line in the corresponding place. The AI Assistant will provide the subsequent code.
Method 2: Add code comments at the corresponding place, and then press the Enter key to start a new line. The AI assistant will read and comprehend the code comments and then provide the code you want.
After Trae AI provides its suggested code, hover the mouse to the code and accept or clear the code as needed:
- Click Accept or press the Tab key to add all suggested code.
- Click Accept Word or use keyboard shortcut (Ctrl + →) to add the suggested code word by word.
- Press the Esc key to clear the suggested code.
Code completion pro (Beta) 
Based on the last edit and the current code context, Trae AI is able to predict the next code code change and provide recommended code.
You can place the cursor at the desired position and then use the shortcut (macOS: Control + Shift + Enter; Windows: Ctrl + Shift + Enter) to trigger code completion pro and use the Tab key to accept the recommended code.
When you accept a suggested code snippet, it will trigger the next code recommendation. You can first press the Tab key to jump to the corresponding line of code, and then press the Tab key again to accept the recommended code.
Code completion pro is enabled by default. You can manage this feature on the Trae AI Settings panel.
Code generation 
Trae AI is capable of generating corresponding code snippets based on your natural language description.
- Fill in your description in the input box.
- Click the Send button or press the Enter key.
- Trae AI generates the code snippet you want.
Perform the following operations as needed:
- Click the Copy button to copy the code snippet in the code box.
- Click the Insert button to insert the code snippet into the corresponding location.
- Click the Add File button to generate the code snippet as a separate file.
- Click the Apply button to display the generated code as a diff in the original file, then choose to accept or reject the new code.
Code editing 
Trae AI is able to edit selected code, including refactoring, optimization, modifying some logic, etc. You can describe your code editing requirements in natural language.
- Select the code you want to edit.
- Enter a natural language description in the input box, such as "Optimize the selected code".
- Click the Send button or press the Enter key.
- Trae AI starts to comprehend your request and provide the edited code.
Perform the following operations as needed:
- Click the Copy button to copy the code snippet in the code box.
- Click the Insert button to insert the edited code snippet into the corresponding location, replacing the original code.
- Click the Add File button to generate the edited code snippet as a separate file.
- Click the Apply button to display the edited code as a diff in the original file, then choose to accept or reject the new code.
Code explanation 
After selecting a code snippet, you can send a command to Trae AI to let it explain the code snippet. Below are the ways of sending the command:
- Enter natural language description in the side chat box, for example, explain the selected code snippet;
- Enter the /explaincommand in the side chat box;
- Right-click the selected code snippet and select Trae AI > Explain Code from the shortcut menu;
- Click the Explain button at the top of the code file.
Unit testing generation 
After selecting a code snippet, you can send a command to Trae AI to let it generate unit testing for the selected code snippet. Below are the ways of sending the command:
- Enter natural language description in the side chat box, for example, generate unit testing for the selected code snippet;
- Enter the /testcommand in the side chat box;
- Right-click the selected code snippet and select Trae AI > Generate Test from the shortcut menu;
- Click the Test button at the top the code (for Visual Studio Code) or the left logo (for JetBrains).
Code comments generation 
After selecting a code snippet, you can send a command to Trae AI to let it generate code comments for the selected code snippet.
Note: Trae AI generates function-level code comments by default, and you can specify to generate more detailed inline comments through natural language.
Below are the ways of sending the command:
- Enter natural language description in the side chat box, for example, generate code comments for the selected code snippet;
- Enter the /doccommand in the side chat box;
- Right-click the selected code snippet and select Trae AI > Generate Comments from the shortcut menu.