This document describes how you can use Gemini Code Assist, an AI-powered collaborator in your IDE, to help you do the following in VS Code or IntelliJ and other supported JetBrains IDEs:
- Generate code for your project with code transformation.
- Receive code completions while you're coding.
- Use smart actions.
If you're using Gemini Code Assist Enterprise, you can use Code customization, which lets you get code suggestions based on your organization's private codebase directly from Gemini Code Assist Enterprise. Learn how to configure code customization.
This document is intended for developers of all skill levels. It assumes you have working knowledge of VS Code or IntelliJ and other supported JetBrains IDEs, and are familiar with Google Cloud. If you prefer, you can also explore Gemini Code Assist in Cloud Shell Editor, Cloud Workstations, and Android Studio.
Before you begin
VS Code
Set up Gemini Code Assist Standard or Enterprise, if you haven't already.
Before testing Gemini Code Assist capabilities in your code file, make sure your file's coding language is supported. For more information on supported coding languages, see Supported coding languages.
If you prefer to use your IDE behind a proxy, see Network Connections in Visual Studio Code.
IntelliJ
Set up Gemini Code Assist Standard or Enterprise, if you haven't already.
Before testing Gemini Code Assist capabilities in your code file, make sure your file's coding language is supported. For more information on supported coding languages, see Supported coding languages.
If you prefer to use your IDE behind a proxy, see HTTP Proxy.
Generate code with prompts
The following sections show you how to use Gemini Code Assist to
generate code with the example prompt Function to create a Cloud Storage
bucket inside your code file. You can also select a part of your code and then
prompt Gemini Code Assist for help through the chat feature, and
receive and accept or reject code suggestions while you code.
Prompt Gemini Code Assist with code transformation
Code transformation allows you to use commands or natural language prompts in the Quick Pick menu to request modifications to your code, and provides you with a diff view to show pending changes to your code. To prompt Gemini Code Assist with code transformation, follow these steps:
VS Code
In your code file, on a new line, press Control+I (for Windows and Linux) or Command+I (for macOS) to open the Gemini Code Assist Quick Pick menu.
In the menu, using the
/generatecommand, enter/generate function to create a Cloud Storage bucketand then press Enter (for Windows and Linux) or Return (for macOS).
Gemini Code Assist generates the code based on your prompt in a diff view.
Optional: To accept these changes, click Accept.
IntelliJ
In your code file, on a new line, press Alt+\ (for Windows and Linux) or Cmd+\ (for macOS) to open the Gemini Code Assist Quick Pick menu.
In the menu, using the
/generatecommand, enter/generate function to create a Cloud Storage bucketand then press Enter (for Windows and Linux) or Return (for macOS).
Gemini Code Assist generates the code based on your prompt in a diff view.
Optional: To accept these changes, click Accept Changes.
You can use the following code transformation commands in your IDE:
/fix: Fix issues or errors in your code. Example:/fix potential NullPointerExceptions in my code./generate: Generate code. Example:/generate a function to get the current time./doc: Add documentation to your code. Example:/doc this function.