Code completion
Basic code completion helps you complete statements, database object names, parameters, and keywords within the visibility scope.
DataGrip analyzes the context and suggests the choices that are reachable from the current caret position. Suggestions also include Live templates. Completion is available for a non-English keyboard layout.
Invoke basic completion
By default, DataGrip displays the code completion popup automatically as you type.
Alternatively, you can press Ctrl+Space or select from the main menu.
Code completion is available for custom file types. However, DataGrip does not recognize the structure of such files and suggests options regardless of whether they are appropriate in the current context.
Accept a suggestion from the list
Press Enter or double-click the relevant list item to insert it to the left of the caret.
Press Tab to replace the characters to the right from the caret.
Use Ctrl+Shift+Enter to make the current code construct syntactically correct (balance parentheses, add missing braces and semicolons, and so on).
Use specific keys and custom characters to accept the selected completion suggestion. To enable these features, go to the Editor | General | Code Completion settings page Ctrl+Alt+S and do the following:
To use specific keys, select the Insert selected suggestion by pressing space, dot, or other context-dependent keys checkbox. These keys depend on the language, your context, and so on.
To also use custom characters, enter the characters into the Additional characters to accept the completion field.
Completion actions
Consider the following list of actions that you can perform with basic code completion:
Complete a list of fields for SELECT statements
Complete a list of fields for
SELECTstatements.
Complete JOIN statements by using a foreign key
Complete the
JOINstatement if tables are connected with a foreign key. To invert an order of operands in theJOINcondition, open Settings Ctrl+Alt+S and navigate to . In the section, select the Invert order of operands in auto-generated ON clause checkbox. Compare an order of operands on the following screenshot with this option on and off.
Complete a list of fields for INSERT statements
Complete a list of fields for
INSERTstatements.
Completion for window functions
When you use a window function, DataGrip automatically adds OVER() and puts the caret into the appropriate place.
Complete a list of fields for GROUP BY statements
Complete a list of fields for
GROUP BYstatements.
Complete abbreviated names
Complete names of database objects that are written in camelCase, hyphenated-object-names, or names_with_underscore. To start completion, use the first letters of words in the name.

Complete abbreviated statements
Complete names of abbreviated statements. To start completion, use the first letters of words in the name.

Complete names of new objects
Complete names of newly created objects in a DDL statement (for example, after the
ALTERclause).
Generate aliases
Generate aliases for objects. To display the suggestion list, press Ctrl+Space.
To automatically add an alias for a table when you use auto-completion, go to Settings Ctrl+Alt+S and navigate to . In the section, select the Automatically add aliases when completing table names checkbox. After that, each time you autocomplete a table name, DataGrip will generate an alias for the table.
If you want to set your own aliases for database objects, click the Add alias icon in the Custom aliases table. Type the object name in the Table name column and the desired alias in the Alias column.

Machine learning-assisted completion ranking
DataGrip allows you to prioritize completion suggestions based on choices that other users made in similar situations.
The ML completion mechanism does not add any new elements but orders the elements retrieved from code. Data is not exposed anywhere; it is collected locally.
Enable ML completion ranking
Enable relevance markers
Press Ctrl+Alt+S to open settings and select Editor | General | Code Completion.
Enable the following options:
Mark position changes in the completion popup: use the
and
icons to indicate whether the relevance of a suggestion is increasing or decreasing and therefore the suggestion has moved up or down the suggestion list.
Mark the most relevant item in the completion popup: use the
icon to indicate the most suitable suggestion on the list.

Code completion settings
To configure code completion settings, go to the Editor | General | Code Completion settings page Ctrl+Alt+S. For more information about the settings, refer to the Code Completion topic.
Completion tips and tricks
Autocomplete HTTP constants by typing the code number
After you specify an imported package name, such as
http, you can type404to autocomplete the value tohttp.StatusNotFound.
Narrow down the suggestion list
Narrow down the suggestion list by typing any part of a word (even characters from somewhere in the middle) or invoking code completion after a dot separator .
DataGrip displays suggestions containing the characters you've entered, regardless of their position. This makes the use of wildcards unnecessary.
In case of CamelCase or snake_case names, type the initial letters only. DataGrip automatically recognizes and matches the initial letters.

View reference
You can use the Quick Information view by pressing Ctrl+Q or automatically when you select an entry in the suggestion list:

Troubleshooting
If code completion does not work, this may be due to one of the following reasons:
The Power Save Mode is on (). Turning it on minimizes power consumption of your laptop by eliminating the background operations, including error highlighting, on-the-fly inspections, and code completion.
Code completion popup might not appear automatically if it takes too long to gather the completion options. For example, if the computer is busy with another task. In this case, you may still activate the completion popup manually via Ctrl+Space.
