---
metadata:
  - name: generator
    content: Diplodoc Platform v5.63.0
alternate:
  - https://vibe.sourcecraft.dev/portal/docs/en/code-assistant/operations/autocompletion.md
  - https://vibe.sourcecraft.dev/portal/docs/ru/code-assistant/operations/autocompletion.md
  - href: https://vibe.sourcecraft.dev/portal/docs/en/code-assistant/operations/autocompletion.md
    type: text/markdown
    title: Markdown version
  - href: https://vibe.sourcecraft.dev/portal/docs/en/code-assistant/llms.txt
    rel: describedby
title: Running SourceCraft Code Assistant in code autocompletion mode
description: How to use Code Assistant in code autocompletion mode.
---
> **Documentation Index:** Fetch the complete configuration index at https://vibe.sourcecraft.dev/portal/docs/en/llms.txt


# Code autocompletion in SourceCraft Code Assistant

<!-- source: en/_includes/code-assistant/vscode-ui-language.md -->
{% note info %}

The interface language of the Visual Studio Code plugin depends on the selected IDE language.

{% endnote %}
<!-- endsource: en/_includes/code-assistant/vscode-ui-language.md -->

<!-- source: en/_includes/code-assistant/instruction-autocompletion.md -->
<!-- source: en/_includes/code-assistant/syntax-support.md -->
The smart autocompletion mode explicitly supports code autocompletion for the following programming languages and frameworks:

* C++
* Go
* Java
* JavaScript/TypeScript
* Kotlin
* Python
* Scala
* SQL
* Swift

Autocompletion may also work for other languages. For languages ​​that are less represented in public repositories, the number and quality of autocompletion prompts will be lower.
<!-- endsource: en/_includes/code-assistant/syntax-support.md -->

## Use case {#examples}

In this example, we use the [_insert_](#insert) mode to revise the code, and then, the [_replace_](#replace) mode, which provides suggestions for the next lines based on the edits we made:

<iframe width="640" height="360" src="https://runtime.strm.yandex.ru/player/video/vplvc2ilmvxzsfk4bkmf?autoplay=0&mute=0" allow="autoplay; fullscreen; picture-in-picture; encrypted-media" frameborder="0" scrolling="no"></iframe>

Here, after we have changed the argument name, the _replace_ mode updates it accordingly in the other lines:

<iframe width="640" height="360" src="https://runtime.strm.yandex.ru/player/video/vplvnuo2g2jw2fjoybgf?autoplay=0&mute=0" allow="autoplay; fullscreen; picture-in-picture; encrypted-media" frameborder="0" scrolling="no"></iframe>

## Insert mode {#insert}

The _insert_ mode in Code Assistant can suggest the most suitable options to complete the current line or word.

<!-- source: en/_includes/code-assistant/auto-manual-modes.md -->
Code Assistant analyzes your code context and provides the following types of suggestions:
* Automatic.
* User-triggered (**Ctrl** + **Space**). In Visual Studio Code, you can also use **Ctrl** + **Enter**.
<!-- endsource: en/_includes/code-assistant/auto-manual-modes.md -->

1. Open the IDE and create a test file named `server.cpp` with the following contents:

    ```cpp
    // simple web-server to work with sockets

    #include <iostream>
    #include <string>
    #include <sys/socket.h>
    #include <netinet/in.h>
    #include <unistd.h>

    using namespace std;

    int main() {

    }
    ```

1. In the `int main()` section, start typing something, e.g., `//create socket`. See the Code Assistant suggestion:

    ```cpp
    ...
    int main() {

    //create socket
    int sockfd = socket(AF_INET, SOCK_STREAM, 0);

    }
    ```

1. Select an action for the suggestion:

    {% list tabs group=ide %}

    - Visual Studio Code {#vscode}

      <!-- source: en/_includes/code-assistant/actions-with-suggestions.md -->
      * Click **Tab** to accept the suggestion.
      * To start accepting the suggestion word by word, press **Ctrl** + **→** for Windows or Linux or **Command** + **→** for macOS.
      * To discard the suggestion, press **Esc**.
      <!-- endsource: en/_includes/code-assistant/actions-with-suggestions.md -->

      * If there are multiple suggestions, you can switch between them using **Alt** + **[** and **Alt** + **]** for Windows or Linux or **Option** + **[** and **Option** + **]** for macOS.

      ![image](../../_assets/code-assistant/vsc-test-autocomplete-screen.png)

    - JetBrains IDE {#jb}

      * Click **Tab** to accept the suggestion.
      * To discard the suggestion, press **Esc**.

      ![image](../../_assets/code-assistant/jb-test-autocomplete-screen.png)

    {% endlist %}

You can also watch our Code Assistant video tutorial [here](https://sourcecraft.dev/portal/code-assistant/).

## Replace mode {#replace}

The _replace_ mode in Code Assistant can suggest corrections and renaming options in the current file code based on the changes you have made.

1. Open the IDE and create a test file named `fibonacci.py` with the following contents:

   ```py
   def fibonacci(k):
       if k == 0:
           return 0
       elif k == 1:
           return 1
       else:
           return fibonacci(k-1) + fibonacci(k-2)
   
   print(fibonacci(10))
   ```

1. For example, change the variable name from `k` to `n`. See the Code Assistant corrections:

   ```py
   def fibonacci(n):
       if n == 0:
           return 0
       elif n == 1:
           return 1
       else:
           return fibonacci(n-1) + fibonacci(n-2)
   
   print(fibonacci(10))
   ```

   Code Assistant suggests corrections line by line. Move the cursor to the relevant line to see a correction from Code Assistant.

1. Select what to do with the suggestion:

   * Click **Tab** to accept the suggestion.
   * To discard the suggestion, press **Esc**.

The model takes code revision history into account. Depending on this history, the suggestions may vary significantly.
<!-- endsource: en/_includes/code-assistant/instruction-autocompletion.md -->

## Suggestion indicator {#help-indicator}

<!-- source: en/_includes/code-assistant/help-indicator.md -->
<!-- source: en/_includes/code-assistant/help-indicator-load.md -->
When generating a suggestion, the ![image](../../_assets/code-assistant/loading.svg) loading icon will appear to the left of the editable code. If generation stops or there is no result, you will see the ![image](../../_assets/code-assistant/chat_crossed.svg) (no suggestion) icon.
<!-- endsource: en/_includes/code-assistant/help-indicator-load.md -->

The suggestion indicator is enabled by default.

To enable or disable the indicator:

{% list tabs group=ide %}

  - Visual Studio Code {#vscode}

    1. In the left-hand panel, click ![image](../../_assets/code-assistant/vsc-icon-small.svg).
    1. In the panel that opens, select ![image](../../_assets/console-icons/gear.svg) **Settings**.
    1. Navigate to **Autocompletion**.
    1. In the settings window that opens, enable or disable the **Code Assistant suggestion indicator** and **Code Assistant load indicator**.

    ![image](../../_assets/code-assistant/vsc-settings-screen.png)

  - JetBrains IDE {#jb}

    1. In the top-right corner, click ![image](../../_assets/console-icons/gear.svg) and select **Settings...**.
    1. In the left-hand column, select **SourceCraft Code Assistant**.
    1. Enable or disable **Disable suggest indicator**.
    1. To save the settings, click **Apply**.

    ![image](../../_assets/code-assistant/jb-settings-screen.png)

{% endlist %}
<!-- endsource: en/_includes/code-assistant/help-indicator.md -->

#### Useful links {#see-also}

* [Getting started with SourceCraft Code Assistant](https://vibe.sourcecraft.dev/portal/docs/en/code-assistant/index.md)
* [SourceCraft Code Assistant chat interface in the JetBrains IDE](https://vibe.sourcecraft.dev/portal/docs/en/code-assistant/operations/chat.md)
* [SourceCraft Code Assistant overview](https://vibe.sourcecraft.dev/portal/docs/en/code-assistant/concepts/index.md)