You can prompt Gemini from the code editor for code suggestions to modify, optimize, or add code to your app as follows:
- To get the prompt input field, do one of the following from the code
editor:
- Right-click in the code editor and select Gemini > Generate code from the context menu.
- Highlight code that you want Gemini to modify, right-click in the code editor, and select Gemini > Transform code from the context menu.
- Press CTRL+\ (Command+\ on macOS).
- Prompt Gemini by describing how you want to modify or add to your code and press Enter. After Gemini processes your request, you should see a code diff. With the code diff, you can review and accept only the suggestions you want.
Review the code diff and do one of the following:
- Further modify the suggested code by clicking Refine and entering a new prompt.
- Click Accept Changes to add the suggested changes to your code.
Things to try:
- "Simplify this code"
- "Make this code idiomatic"
- "Generate a new function that does <description>"
- "Add documentation for this code"