Cody Tutorial
This tutorial gives you a quick walkthrough of leveraging Cody for autocompletion, chat, explaining code, and running commands in VS Code.
Code Autocomplete
Start writing code and Cody will complete the line (or the entire function) for you. Press Tab to accept the suggestion.
✨ Pro-tips for using Cody autocomplete
- Autocomplete uses the surrounding code and context to inform the suggestions, so if you need to guide it you can add a comment above the line you're editing.
- You can hover over the grey suggestion to see a toolbar of alternative suggestions, as well as other options such as accepting a single word at a time.
- You can use the "Trigger Autocomplete at Cursor" command to trigger a code suggestion at any time, using the default keyboard shortcut of
Opt+L
/Alt+L
.
Chat
Answer questions about general programming topics, or specific to your codebase, with Cody chat. You can choose between LLMs, @-mentions files and symbols, and enable enhanced repository-wide code context.
You can start a chat at any time using the default keyboard shortcut of Opt+L
/Alt+L
.
✨ Pro-tips for using Cody chat
- Tagging specific files and symbols gives the selected LLM more context to help answer your questions more accurately.
- If you want to chat directly with the LLM without any additional context adding, delete the @-mentions that are automatically inserted in each new Cody chat and just ask a plain question.
Cody Commands
Cody has a range of commands for explaining code, generating unit tests, adding documentation, and more.
To get started: select code in your editor, right click, and choose a command from the "Cody" menu.
You can also use the Cody: Commands Menu which has the default keyboard shortcut of Opt+C
/Alt+C
.
✨ Pro-tips for using Cody commands
- You can build your own Custom Commands (Beta) with custom prompts, output into chat or perform code edits, and more.
Edit Code
You can ask Cody to perform code edits using the Edit Code command. This will edit code according to your instructions, giving you the chance to retry the edit with a new prompt, undo, or accept the change.
To get started: select code in your editor, right click, and choose "Cody → Edit Code".
You can also use the default keyboard shortcut of Opt+K
/Alt+K
.
✨ Pro-tips for code editing with Cody
- You can open the 💡 menu, with an "Cody: Edit Code" option, by selecting any line of code and using the keyboard short
Command
.
on macOS orCrtl
.
on Windows & Linux. - If you start an empty line and open the 💡 menu (using the keyboard short
Command
.
on macOS orCtrl
.
on Windows & Linux) you can use "Cody: Generate Code" to generate new lines of code based on instructions. - You define your own custom code editing commands using Custom Commands (Beta), by setting the
commands.<id>.mode
property.
Explain Code
Use Cody to get an in-depth explanation of any piece of code in any programming language.
To get started, select code in your editor, right-click, and choose "Cody > Explain Code".
You can also run this command from the Cody: Commands Menu, which has the default keyboard shortcut of Opt+C
/Alt+C
.
✨ Pro-tips for understanding code with Cody
- Cody can also explain errors too, with the "Ask Cody to Explain" option in the 💡 menus, or by right clicking on any items in the "Problems" tab of VS Code.
- You can define your own custom code to explain commands to suit, such as a prompt that requests an explanation focused on potential security issues, using Custom Commands (Beta).
Fix Code
Something wrong with your code? Use Cody’s "Ask Cody to Fix" command to fix it, or explain the problem.
✨ Pro-tips for fixing code with Cody
- You can open the 💡 menu, with an "Ask Cody to Fix" option, by moving the cursor over any line of code with an error and using the keyboard short
Command
.
on macOS orCrtl
.
on Windows & Linux. - You can also right click on any items in the "Problems" tab of VS Code and select "Ask Cody to Fix"
Keyboard Shortcuts
Cody offers an extensive set of default key bindings (keyboard shortcuts) to make it easy for you to perform various actions using the keyboard. You can also update these bindings in the Keyboard Shortcuts Editor
.
Keyboard Shortcuts Editor
The Keyboard Shortcuts Editor
allows you to easily update the default bindings (keyboard shortcuts). This is particularly useful if the default key bindings conflict with your current or preferred key bindings. By accessing the Keyboard Shortcuts Editor
in VSCode or Keymap Shortcuts Editor
in JetBrains, you can search for specific commands, reassign keybindings, and customize your keyboard shortcuts to suit your workflow.
Getting Started (VSCode)
To get started:
- Click on the Keyboard Shortcuts icon in the Cody sidebar under
**SETTINGS AND SUPPORT**
to open theKeyboard Shortcuts Editor
. - In the
Keyboard Shortcuts Editor
, you can search for a specific command by typing in the search bar. - Once you have found the command you want to reassign keybindings for, click on it to select it.
- Follow the instruction on screen to assign a new keybinding.
Getting Started (JetBrain)
To get started:
- Click on the IntelliJ IDEA icon at the top menu bar and then click on Keymap from the dropdown to open the
Keymap Shortcuts Editor
. - In the
Keymap Shortcuts Editor
, you can search for a specific command by typing in the search bar. - Once you have found the command you want to reassign keymappings for, click on it to select it.
- Follow the instruction on screen to assign a new keymappings.
✨ Pro-tips for assigning keyboard shortcuts for Cody
- You can assign key bindings (keyboard shortcuts) to individual custom commands.