Use AI in editor
This functionality relies on the AI Assistant plugin that requires an additional license.
For more information about licensing and enabling AI Assistant, refer to JetBrains AI Service licensing and Enable AI Assistant plugin.
This functionality relies on the AI Assistant plugin, which you need to install and enable.
Press CtrlAlt0S to open settings and then select Plugins.
Open the Marketplace tab, find the AI Assistant plugin, and click Install (restart the IDE if prompted).
Generate code and use prompts right in the editor.
Select a piece of code that you want to modify or place the caret anywhere in the editor and press Ctrl0\.
Alternatively, right-click anywhere in the editor to open the context menu, select AI Actions and then Generate Code.
note
If you select a piece of code and ask AI Assistant to generate code, it will only suggest changes for the selected piece of code.
If you place the caret anywhere in the editor before asking AI Assistant to generate code, the generated code will be inserted in the editor at the caret.
In the input field, write your prompt and press Enter.
Wait for the generation to complete. The generated code will be shown in the same editor tab where you have invoked the input field.
If you want to improve the generated code, in the same input field, write a follow-up message with the new requirements and press Enter.
AI Assistant will regenerate the code while taking into account the new specifications.
If you want to regenerate the answer, click Regenerate or press CtrlF5.
Click Accept to insert the generated fragment.
If you want to revert some of the suggested changes, in the gutter, click Revert.
To discard all the suggested changes, click Discard in the input popup.
tip
AI Assistant can also understand prompts as you type directly in the editor, without invoking the code generation input field.
Type your prompt right in the editor where you want to make adjustments and press Tab. Undo the changes by pressing Ctrl0Z.
AI Assistant can explain and fix SQL query execution errors in editor tabs. The corresponding actions are available in the error message area.
AI Assistant can explain the SQL execution error in your code. You can also ask further questions about the error in AI chat.
This feature requires attaching the database schema to suggest proper explanations and fixes.
After running an SQL query and encountering a query execution error, click Explain with AI in the error message area.
DataGrip opens AI chat with an automatically sent prompt and AI Assistant’s response, providing an explanation of the error.
AI Assistant can fix the SQL execution error in your code.
This feature requires attaching the database schema to suggest proper explanations and fixes.
After running an SQL query and encountering a query execution error, click Fix with AI in the error message area.
AI Assistant generates a fix for the query execution error in the editor.
tip
If you'd like to provide feedback on this feature, click Yes or No in the Do you like the generated result? popup.
When DataGrip detects code that produces errors, it suggests a quick-fix directly within the editor.
AI Assistant can suggest more precise fixes applicable to your specific case due to its context awareness. This feature requires attaching the database schema to suggest proper explanations and fixes.
Place the caret at a highlighted error in the editor. Then click the red light bulb icon or press AltEnter to open the list of suggestions.
Click Fix with AI Assistant.
AI Assistant sends the entire file together with database schema as context to the LLM to determine which fix would be most suitable in this particular case.
The code is then updated directly in the editor.
Thanks for your feedback!