In our previous tutorial, we explained how to get started with GitHub Copilot AI Tool in VS Code. In this tutorial, we will cover useful shortcuts for GitHub Copilot in VS Code.
As we know, GitHub Copilot is an AI-powered tool that can be accessed in VS Code. It helps write code faster and with less effort. We can use Copilot in VS Code through the Chat view, directly in the editor, from the integrated terminal, and via AI-powered enhancements in the VS Code user interface.
So here are the must-use GitHub Copilot shortcuts for VSCode to boost your efficiency:
1. Copilot Chat
You can use natural language to chat with GitHub Copilot for help with your code. The tool provides an inline chat feature and a chat view feature for assistance. You can also ask Copilot to explain blocks of code and programming concepts.
So here is detail for shortcuts to access chat features.
Inline Chat
This is the most commonly used feature of GitHub Copilot. Programmers use this feature to get help with existing code.
Here are the shortcuts to access this feature:
Ctrl+I
Simply select the code, enter the command above to open the inline chat, and type your help request to get a solution.
Quick Chat
If you have a quick question while writing code and need help, you can easily access the Quick Chat feature in GitHub Copilot. Just enter the command below to open Quick Chat and ask your question:
Ctrl+Shift+Alt+L
Chat View
If you want a more detailed conversation, you can use the Chat View feature in GitHub Copilot. The Chat View allows for natural language conversations. Simply enter the command below to open Chat View and start a chat to get help with your code and project:
Ctrl+Alt+I
Copilot Edits View
When using inline chat or Chat View, GitHub Copilot may edit your code. In such cases, Copilot maintains a session of all edits across multiple files. If you want to review each edit, just enter the command below to open the Copilot Edits View and track code changes across multiple files:
Ctrl+Shift+I
You can enter below command to accept all edits:
Ctrl+Enter
You can also discard all edits by entering below command:
Ctrl+Backspace
2. Debugging with GitHub Copilot
You can debug your code in VSCode with the help of Github Copilot. You can setup debugging configuration for your project to get suggestions for fixing issues discovered during coding. So here you will learn how to debug your code in VsCode with Copilot.
As we know that the VSCode uses the launch.json file to store debug configuration. Copilot can help you create and customize this file to set up debugging for your project.
So when you enter below debugging command to open chat view and it will start debugging by creating the launch.json file.
Ctrl+Alt+I
After Chat View open, enter the /startDebugging command. The Copilot automatically setup debugging for your project. It will fix code in your project files and also list issue details with fixes. You can also use natural languages for debugging.
You can enter /fix to ask Copilot for suggestions on resolving compiler or linting errors.
You can also use copilot-debug terminal command that simplifies the process of configuring and starting a debugging session.
Just enter Ctrl+ open the integrated terminal and enter copilot-debug followed by your application’s start command.
copilot-debug python app.py
or
copilot-debug node app.js
Github Copilot also launches a debugging session for your application. You can now use the built-in debugging features in VS Code.