Code with Gemini Code Assist Standard and Enterprise

This document describes how you can useGemini Code Assist Standard andEnterprise, anAI-powered collaborator in your IDE, to help you do the following in VS Code orIntelliJ and othersupported JetBrains IDEs:

  • Generate code for your project with code transformation.
  • Receive code completions while you're coding.
  • Use smart actions.

If you're usingGemini Code Assist Enterprise,you can useCode customization,which lets you get code suggestions based on your organization's privatecodebase directly from Gemini Code Assist Enterprise. Learnhow to configure code customization.

This document is intended for developers of all skill levels. It assumes youhave working knowledge of VS Code or IntelliJ and other supported JetBrainsIDEs, and are familiar with Google Cloud. If you prefer, you can alsoexplore Gemini Code Assist inCloud Shell Editor,Cloud Workstations,andAndroid Studio.

Note: The behaviour of code generation, completion, and transformation arenon-deterministic when used simultaneously with other plugins that eitherimplement the same shortcuts and/or use the same platform API to process theseactions.

Before you begin

VS Code

  1. Set up Gemini Code Assist Standard or Enterprise, if you haven't already.

  2. Before testing Gemini Code Assist capabilities in yourcode file, make sure your file's coding language is supported. For moreinformation on supported coding languages, seeSupported coding languages.

  3. If you prefer to use your IDE behind a proxy, seeNetwork Connections in Visual Studio Code.

IntelliJ

  1. Set up Gemini Code Assist Standard or Enterprise, if you haven't already.

  2. Before testing Gemini Code Assist capabilities in yourcode file, make sure your file's coding language is supported. For moreinformation on supported coding languages, seeSupported coding languages.

  3. If you prefer to use your IDE behind a proxy, seeHTTP Proxy.

Generate code with prompts

The following sections show you how to use Gemini Code Assist togenerate code with the example promptFunction to create a Cloud Storagebucket inside your code file. You can also select a part of your code and thenprompt Gemini Code Assist for help through the chat feature, andreceive 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 inthe Quick Pick menu to request modifications to your code, and provides you witha diff view to show pending changes to your code. To promptGemini Code Assist with code transformation, follow these steps:

VS Code

  1. In your code file, on a new line, pressControl+I (for Windowsand Linux) orCommand+I (for macOS) to open theGemini Code Assist Quick Pick menu.

  2. In the menu, using the/generate command, enter/generate function tocreate a Cloud Storage bucket and then pressEnter (for Windowsand Linux) orReturn (for macOS).

    Gemini Code Assist generates code with the /generate command.

    Gemini Code Assist generates the code based on your promptin a diff view.

    Gemini Code Assist opens a diff view to show generated code.

  3. Optional: To accept these changes, clickAccept.

IntelliJ

  1. In your code file, on a new line, pressAlt+\ (for Windows andLinux) orCmd+\ (for macOS) to open theGemini Code AssistQuick Pick menu.

  2. In the menu, using the/generate command, enter/generate function tocreate a Cloud Storage bucket and then pressEnter (forWindows and Linux) orReturn (for macOS).

    Code transformation generate function in IntelliJ Gemini Code Assist

    Gemini Code Assist generates the code based on your promptin a diff view.

    Code transformation diff view in IntelliJ Gemini Code Assist

  3. Optional: To accept these changes, clickAccept Changes.

    You can use the following code transformation commands in your IDE:

    • /fix: Fix issues or errors in your code. Example:/fix potentialNullPointerExceptions in my code.
    • /generate: Generate code. Example:/generate a function to get thecurrent time.
    • /doc: Add documentation to your code. Example:/doc this function.
    • /simplify: Simplify your code. Example:/simplify if statement inthis code.

Prompt Gemini Code Assist in a code file with a comment

If you prefer, you can also prompt Gemini Code Assist in yourcode file with a comment by following these steps:

VS Code

  1. On a new line, enter the commentFunction to create a Cloud Storagebucket, and then pressEnter (for Windows and Linux) orReturn (for macOS).

  2. To generate code, pressControl+Enter (for Windows and Linux)orControl+Return (for macOS).

    Next to your prompt text in your code file,Gemini Code Assist generates the code in the form of ghosttext.

  3. Optional: To accept the generated code, pressTab.

IntelliJ

  1. In your code file, on a new line, enter the commentFunction to create aCloud Storage bucket.

  2. To generate code, pressAlt+G (for Windows and Linux) orOption+G (for macOS). Alternatively, you can right-click nextto the comment and selectGenerate Code.

    Gemini Code Assist generates the code below your comment inthe form of ghost text.

  3. Optional: To accept the generated code, pressTab.

Optional: Change keyboard shortcut for generating code

If the default keyboard shortcut for generating code isn't working as outlinedin the previous section, you canchange the keyboard shortcut.

Get code completions

While you write code, Gemini Code Assist makes inline codesuggestions, also known ascode completions, that you can either accept orignore. To get code completions, follow these steps:

VS Code

  1. In your code file, on a new line, start writing a function. For example,if you're in a Python file, writedef.

    Gemini Code Assist suggests code in the form of ghost text.

  2. To accept the code suggestion from Gemini Code Assist,pressTab. Otherwise, to ignore the suggestion, pressEsc or continue writing your code.

IntelliJ

  1. In your code file, on a new line, start writing a function. For example,if you're in a Python file, writedef.

    Gemini Code Assist suggests code in the form of an inlinesuggestion.

  2. To accept the code suggestion from Gemini Code Assist,pressTab. Otherwise, to ignore the suggestion, pressEsc or continue writing your code.

  3. Optional: If you prefer to use a different shortcut key to accept theinline suggestion, hold your pointer over the inline suggestion and click theTab dropdown that appears. Then, select your preferred shortcut or clickCustom to enter your own shortcut.

    Gemini provides a dropdown menu to change your shortcut to accept an inline suggestion.

Optional: Disable code completion

Code completion is enabled by default. If you want to disable code completion,follow these steps:

VS Code

  1. In your IDE, clickCode (for macOS) orFile (for Windows andLinux), and then navigate toPreferences>Settings.

  2. On theUser tab of theSettings dialog, navigate toExtensions>Gemini Code Assist.

  3. Scroll until you find theGeminicodeassist > Inline Suggestions: Enable Autolist, and then selectOff.

    This turns off the inline suggestions. You can still pressControl+Enter (for Windows and Linux) orControl+Return (for macOS) to manually trigger inlinesuggestions.

IntelliJ

In the status bar of your IDE, clicksparkGemini CodeAssist: Active and selectEnable AI Code Completion.

Gemini Code Completion button in IntelliJ status bar.

This disables the code completion setting, andGemini Code Assist no longer makes inline suggestions untilyou enable the setting again.

Use Next Edit Predictions

Preview

This product or feature is in preview. Products and features that arein preview are available "as is".

While code completion only suggests changes at your cursor in a code file, NextEdit Predictions provide predicted code suggestions throughout the file, even inlocations away from the cursor.

You can enable Next Edit Predictions in the settings of your IDE.

To use Next Edit Predictions in your IDE, follow these steps:

VS Code

To begin using Next Edit Predictions, enable the setting:

  1. Navigate tosettingsManage>Settings.

  2. In theUser tab of the settings window, navigate toExtensions>Gemini Code Assist.

  3. Scroll until you findGeminicodeassist > Inline Suggestions: Next EditPredictions.

  4. Select the checkbox to enable Next Edit Predictions in VS Code.

Now that you've enabled the setting, you can start using Next Edit Predictionsin a code file by performing these steps:

  1. In your code file, start writing code. Next Edit Predictions appear whenyou pause or stop typing.

    User triggers the Next Edit Predictions in VS Code Gemini Code Assist.

  2. PressTab to accept the provided Next Edit suggestion.

    User enters the Next Edit Prediction in VS Code Gemini Code Assist.

  3. If you want to accept the next suggestion, pressTab again. Afurther suggestion may appear and the process can again be repeated.Otherwise, pressEsc to dismiss, or continue typing to ignore thesuggestion.

    When you pressTab to enter the suggestion, you can hold yourpointer over the suggestion to see the other suggestions, if applicable.If there are multiple suggestions, you can click the left and right arrowsto cycle through the other suggestions.

    Available Next Edit Predictions in VS Code Gemini Code Assist.

    Whenever you pressEsc to dismiss the suggestion,Gemini Code Assist stops suggesting Next Edit Predictionsfor that specific code block. You continue to receive suggestions when youmove to another section of your code.

    Note: Gemini Code Assist only provides Next EditPredictions in the file that you're currently in.Gemini Code Assist doesn't provide Next Edit Predictions inother files.

IntelliJ

To begin using Next Edit Predictions, enable the setting:

  1. Navigate toFile>Settings>Tools>Gemini.

  2. In theCompletion section, select theNext Edit Predictionscheckbox to enable the feature.

Now that you've enabled the setting, you can start using Next Edit Predictionsin a code file by performing these steps:

  1. In your code file, start writing code. Next Edit Predictions appear whenyou pause or stop typing.

    User triggers the Next Edit Predictions in IntelliJ Gemini Code Assist.

  2. PressTab to accept the provided Next Edit suggestion.

    User enters the Next Edit Prediction in IntelliJ Gemini Code Assist.

  3. If you want to accept the next suggestion, pressTab again. Afurther suggestion may appear and the process can again be repeated.Otherwise, pressEsc to dismiss, or continue typing to ignore thesuggestion.

    Whenever you pressEsc to dismiss the suggestion,Gemini Code Assist stops suggesting Next Edit Predictionsfor that specific code block. You continue to receive suggestions when youmove to another section of your code.

    Note: Gemini Code Assist only provides Next EditPredictions in the file that you're currently in.Gemini Code Assist doesn't provide Next Edit Predictionsthat would impact code in other files.

Get more relevant suggestions with remote repository context

You can get more contextually aware and relevant code suggestions by directingGemini Code Assist to focus on specific remote repositories.This is useful when your task centers on a specific set of microservices,libraries, or modules.

Before you begin

Before you use a remote repository as context, you must firstindex and configure it for code customization.

Use a remote repository as context

To direct Gemini Code Assist to use one or more repositoriesas the primary context for your prompts:

  1. In your IDE's chat, start your prompt with the@ symbol.A list of your available indexed remote repositories appears.
  2. Select the repository (or repositories) you want to use for context fromthe list. You can also start typing the repository name to filter the list.
  3. After selecting the repositories, write the rest of your prompt.

Gemini Code Assist then prioritizes the selected repositorieswhen generating a response.

Example prompts

This section includes examples of how you can get more relevant suggestions withremote repository context.

  • Understand a repository
    • @REPOSITORY_NAME What is the overall structure of this repository?
    • @REPOSITORY_NAME I'm a new team member. Can you give me an overview ofthis repository's purpose and key modules?
  • Generate and modify code
    • @REPOSITORY_NAME Implement an authentication function similar to the onein this repository.
    • @REPOSITORY_NAME Refactor the following code to follow the conventions inthe selected repository.
    • Use the library-x in @REPOSITORY_A_NAME-A and implement the function-x
  • Test
    • @UNIT_TEST_FILE_NAME Generate unit tests for module-x based on the examplesin the selected file.

By using remote repositories as a focused source of context, you can get moreaccurate and relevant suggestions from Gemini Code Assist, whichcan help you code faster and more efficiently.

Use smart actions

To help you be more productive while minimizing context switching,Gemini Code Assist provides AI-powered smart actions directly inyour code editor. When you select your code in your code editor, you can viewand select from a list of actions relevant to your context.

To use smart actions in your code, follow these steps:

VS Code

  1. In your code file, select a block of code.

  2. Next to the selected code block, clicklightbulbShow CodeActions.

    Smart actions lightbulb icon appears after selecting a block of code in VS Code.

  3. Select an action such asGenerate unit tests.

    Gemini Code Assist generates a response that's based on theaction you selected.

IntelliJ

  1. In your code file, select a line or block of code.

  2. Right-click the selected code and select a smart action, likeGenerate unit tests.

    Selecting the smart action will automatically promptGemini Code Assist to generate a response to the prompt intheGemini Code Assist tool window.

Use code transformation quick fix

If there's an error in your code, Gemini Code Assist gives youthe option to apply aquick fix to the error with code transformation.

To apply a quick fix in your code file, follow these steps:

VS Code

  1. In your code file, hold your pointer over the squiggly error line andselectQuick Fix, and then select/fix.

    Code transformation quick fix in the IDE.

  2. When the quick fix is applied, a diff view appears. To accept thesechanges, clickAccept.

IntelliJ

  1. In your code file, click the red error bulb icon, which indicates an errorin your code, and selectFix with Gemini.

    Code transformation option to fix with Gemini in the IDE.

  2. When the fix is applied, a diff view appears. To accept these changes,clickAccept.

Exclude files from local context

By default, Gemini Code Assist excludes files from local use inthe context for code completion, code generation, code transformation, and chatif the files are specified in a.aiexclude or.gitignore file.

To learn how to exclude files from local use, seeExclude files from Gemini Code Assist use.

Disable code suggestions that match cited sources

Gemini Code Assist provides citation information when it directlyquotes at length from another source, such as existing open source code. Formore information, seeHow and when Gemini cites sources.

To prevent code that matches cited sources from being suggested to you, do thefollowing:

VS Code

  1. In the activity bar of your IDE, clickManage>Settings.

  2. In theUser tab of the settings window, navigate toExtensions>Gemini Code Assist.

  3. Scroll until you findGeminicodeassist > Recitation: Max Cited Length.

  4. Set the value to0.

Gemini Code Assist no longer suggests code to you that matchescited sources.

IntelliJ

  1. In the status bar of your IDE, clicksparkGemini Code Assist: Active and select then selectConfigure Gemini.

  2. Expand theAdvanced settings section, and then selectBlock selections that match external cited sources.

  3. ClickOK.

Gemini Code Assist no longer suggests code to you that matchescited sources.

Known issues

This section outlines the known issues of Gemini Code Assist:

VS Code

  • Chat responses may be truncated when they include an updated version of alarge open file

    To work around this issue, select a smaller section of code and include anadditional directive in the chat prompt, such asonly output the selectedcode.

  • Vim: Cannot accept or dismiss code generation suggestions unless ininsert mode

    When using the Vim plugin in normal mode, you can't accept or dismiss codesuggestions.

    To work around this issue, pressi to enter insert mode, andthen pressTab to accept the suggestion.

  • Vim: Inconsistent behavior when pressingEsc to dismisssuggestions

    When you pressEsc, both the IDE andGemini Code Assist suggestions are dismissed. This behavioris different from the non-Vim behavior where pressingEscre-triggers Gemini Code Assist.

  • Sign-in attempts keep timing out

    If your sign-in attempts keep timing out, try adding thecloudcode.beta.forceOobLogin setting to yoursettings.json file:

    "cloudcode.beta.forceOobLogin":true
  • License recitation warnings don't persist across sessions

    If license recitation warnings don't persist across sessions, refer to thepersistent logs:

    1. ClickView>Output.

    2. SelectGemini Code Assist - Citations.

  • Connectivity issues in the Gemini Code Assist outputwindow

    If you see a connection error or other connectivity problems in theGemini Code Assist output window, try the following:

    • Configure your firewall to allow access tooauth2.googleapis.com andcloudaicompanion.googleapis.com.

    • Configure your firewall to allow communication over HTTP/2, which gRPCuses.

    You can use thegrpc-health-probe tool to test connectivity. Asuccessful check results in the following output:

    $ grpc-health-probe -addr cloudaicompanion.googleapis.com:443 -tlserror: this server does not implement the grpc health protocol(grpc.health.v1.Health): GRPC target method can't be resolved

    An unsuccessful check results in the following output:

    timeout: failed to connect service "cloudaicompanion.googleapis.com:443" within 1s

    To obtain more details, run the following beforegrpc-health-probe:

    export GRPC_GO_LOG_SEVERITY_LEVEL=info
  • 'Activate Gemini Code Assist' still appears afterselecting Gemini Code Assist project

    If youselected your project per theinstructions in this guide, which includes enabling theGemini for Google Cloud API, then there may be an issue with the LS server.

    To find out more details about your issue, perform the following actions:

    1. In the status bar, clicksparkGemini CodeAssist and then selectSend feedback.

    2. ClickShow for any of the log files to see more details and to helptroubleshoot the issue.

IntelliJ

There are no known issues for Gemini Code Assist for IntelliJand other supported JetBrains IDEs.

Leave feedback

To leave feedback of your experience, seeProvide Gemini for Google Cloud feedback.

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-11-05 UTC.