The interface language of the Visual Studio Code plugin depends on the selected IDE language.
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.
Use case
In this example, we use the insert mode to revise the code, and then, the replace mode, which provides suggestions for the next lines based on the edits we made:
Here, after we have changed the argument name, the replace mode updates it accordingly in the other lines:
Insert mode
The insert mode in Code Assistant can suggest the most suitable options to complete the current line or word.
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.
Open the IDE and create a test file named server.cpp with the following contents:
// simple web-server to work with sockets#include<iostream>#include<string>#include<sys/socket.h>#include<netinet/in.h>#include<unistd.h>usingnamespace std;
intmain(){
}
In the int main() section, start typing something, e.g., //create socket. See the Code Assistant 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.
If there are multiple suggestions, you can switch between them using Alt + [ and Alt + ] for Windows or Linux or Option + [ and Option + ] for macOS.
Click Tab to accept the suggestion.
To discard the suggestion, press Esc.
You can also watch our Code Assistant video tutorial here.
Replace mode
The replace mode in Code Assistant can suggest corrections and renaming options in the current file code based on the changes you have made.
Open the IDE and create a test file named fibonacci.py with the following contents:
deffibonacci(k):
if k == 0:
return0elif k == 1:
return1else:
return fibonacci(k-1) + fibonacci(k-2)
print(fibonacci(10))
For example, change the variable name from k to n. See the Code Assistant corrections:
deffibonacci(n):
if n == 0:
return0elif n == 1:
return1else:
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.
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.
Suggestion indicator
When generating a suggestion, the loading icon will appear to the left of the editable code. If generation stops or there is no result, you will see the (no suggestion) icon.
The suggestion indicator is enabled by default.
To enable or disable the indicator:
Visual Studio Code
JetBrains IDE
In the left-hand panel, click .
In the panel that opens, select Settings.
Navigate to Autocompletion.
In the settings window that opens, enable or disable the Code Assistant suggestion indicator and Code Assistant load indicator.
In the top-right corner, click and select Settings....
In the left-hand column, select SourceCraft Code Assistant.