Inline Auto Completion
Use AI-based autocomplete to accept suggestions for code as you write it inside your editor. Inline autocompletions can currently be triggered in Apex and LWC (JavaScript, CSS, and HTML) files.
Inline autocomplete is enabled by default. Click the Agentforce icon in the status bar, or run Agentforce: Toggle Auto Completions to toggle the feature off and on. Run the Agentforce: Toggle Auto Completions for Current File Type command to toggle the feature off and on for the currently active specific file type.
To enable or disable the Inline Autocomplete feature from Settings:
- Select File > Preferences > Settings (Windows or Linux) or Code > Settings > Settings (macOS).
- Under Agentforce for Developers, select Enable Auto Completions then select the language for which to enable the feature.
We disable inline autocomplete when you're idle. The sleeping Agentforce status icon lets you know that inline autocomplete is disabled. You can easily re-enable it by restarting VS Code, or by using the Option (⌥)\ hotkeys to manually generate autocomplete suggestions. Inline autocomplete also re-enables automatically after 1 hour of inactivity.
To select the length of generated inline autocompletions:
- Select File > Preferences > Settings (Windows or Linux) or Code > Settings > Settings (macOS).
- Under Agentforce for Developers, go to Autocompletion Length and select Short or Long from the dropdown.
Note that longer completions can span multiple lines. Short completions typically span only a single line.
If you want a visual indication to let you know that Agentforce is busy generating an autocompletion:
- Select File > Preferences > Settings (Windows or Linux) or Code > Settings > Settings (macOS).
- Under Agentforce for Developers, check Show an indicator to signal that Agentforce is making an autocomplete request.
A sparkle icon () now appears in the editor when Agentforce is working on an autocompletion.
Agentforce for Developers automatically generates code and suggests completions for you as you type. When writing code, you're often doing things like assigning variable values to an SObject
such as Account.name = abc
, or Account.type = Business
in Apex. Pause the cursor after the variable value and watch Agentforce for Developers suggest a completion and fill out the remaining fields in grayed (ghost) text.
To accept an entire suggestion, press Tab. If you have VS Code's Inline Suggest enabled, you can accept the next word of the suggestion using one of these keyboard shortcuts:
Operating System | Accept Next Word |
---|---|
macOS | ⌘→ |
Windows | ⌥→ |
Linux | ⌥→ |
If you don't see a suggestion, make sure Auto Completions are enabled. Run Agentforce: Toggle Auto Completions to toggle the feature off and on. Also, you can always trigger inline suggestions even if you don't have the Auto Completions enabled using the Option (⌥)\ hotkeys to manually generate autocomplete suggestions.
- The completions that you receive are sometimes not formatted correctly. Run Prettier after you've accepted the suggestions.
- Completions sometime populate piecemeal. Accept the partial suggestion and the remainder will populate.
- Suggested completions from multiple providers will all appear as ghost text if you have multiple AI-based Inline Completion extensions enabled. Scroll through them to find the Agentforce for Developers specific suggestion, or disable competing extensions as described in setup.