Skip to content

Commit 5ef4fbd

Browse files
committed
docs(notes): update 2025-03-21-vscode-copilot-en.md
1 parent d9738a3 commit 5ef4fbd

File tree

1 file changed

+115
-0
lines changed

1 file changed

+115
-0
lines changed

notes/2025-03-21-vscode-copilot-en.md

+115
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,119 @@ Here’s how to leverage Copilot in your coding workflow:
118118

119119
---
120120

121+
That’s it! You’re now ready to use GitHub Copilot in VS Code. Start by opening a file, typing some code or a comment, and let Copilot assist you. Enjoy coding smarter!
122+
123+
---
124+
125+
Using GitHub Copilot in Visual Studio Code (VS Code) is straightforward once you set it up. Below is a step-by-step guide to get you started as of March 20, 2025:
126+
127+
---
128+
129+
### Step 1: Install VS Code
130+
- Ensure you have Visual Studio Code installed. Download it from [code.visualstudio.com](https://code.visualstudio.com/) if you haven’t already.
131+
- Update VS Code to the latest version for optimal compatibility (go to `Help > Check for Updates`).
132+
133+
---
134+
135+
### Step 2: Install the GitHub Copilot Extension
136+
1. **Open VS Code**.
137+
2. **Go to the Extensions Marketplace**:
138+
- Click the Extensions icon in the Activity Bar on the left (or press `Ctrl+Shift+X` / `Cmd+Shift+X` on Mac).
139+
3. **Search for "GitHub Copilot"**:
140+
- Type "GitHub Copilot" in the search bar.
141+
- Look for the official extension by GitHub (it’ll have a verified badge).
142+
4. **Install the Extension**:
143+
- Click the `Install` button next to "GitHub Copilot".
144+
5. **Optional: Install Copilot Chat (Recommended)**:
145+
- Search for "GitHub Copilot Chat" and install it as well. This adds conversational AI features like asking questions or generating code via chat.
146+
147+
---
148+
149+
### Step 3: Sign In to GitHub Copilot
150+
1. **Authenticate with GitHub**:
151+
- After installation, a prompt will appear asking you to sign in.
152+
- Click `Sign in to GitHub` in the pop-up or go to the Copilot status icon (bottom-right corner of VS Code) and select "Sign in".
153+
2. **Authorize in Browser**:
154+
- A browser window will open asking you to log into your GitHub account.
155+
- Approve the authorization request by clicking `Authorize Git hypoxia`.
156+
3. **Copy the Code**:
157+
- GitHub will provide a one-time code. Copy it and paste it back into VS Code when prompted.
158+
4. **Verify Activation**:
159+
- Once signed in, the Copilot icon in the status bar should turn green, indicating it’s active. You’ll also see a notification confirming your access.
160+
161+
---
162+
163+
### Step 4: Configure Copilot (Optional)
164+
- **Enable/Disable Suggestions**:
165+
- Go to `File > Preferences > Settings` (or `Ctrl+,` / `Cmd+,`).
166+
- Search for "Copilot" to tweak settings like enabling inline suggestions or disabling it for specific languages.
167+
- **Check Subscription**:
168+
- Copilot requires a subscription ($10/month or $100/year) after a 30-day trial. Students, teachers, and open-source maintainers can apply for free access via [GitHub Education](https://education.github.com/) or the Copilot settings.
169+
170+
---
171+
172+
### Step 5: Start Using Copilot
173+
Here’s how to leverage Copilot in your coding workflow:
174+
175+
#### 1. **Code Suggestions**
176+
- **Inline Autocomplete**:
177+
- Start typing in a file (e.g., `def calculate_sum(` in Python), and Copilot will suggest completions in gray text.
178+
- Press `Tab` to accept the suggestion or keep typing to ignore it.
179+
- **Multi-line Suggestions**:
180+
- Write a comment like `// Function to sort an array` and press Enter. Copilot might suggest an entire implementation (e.g., a sorting algorithm).
181+
- Use `Alt+]` (or `Option+]` on Mac) to cycle through multiple suggestions.
182+
183+
#### 2. **Code Generation from Comments**
184+
- Type a descriptive comment like:
185+
```javascript
186+
// Fetch data from an API and handle errors
187+
```
188+
Press Enter, and Copilot may generate:
189+
```javascript
190+
async function fetchData(url) {
191+
try {
192+
const response = await fetch(url);
193+
if (!response.ok) throw new Error('Network response was not ok');
194+
return await response.json();
195+
} catch (error) {
196+
console.error('Fetch error:', error);
197+
}
198+
}
199+
```
200+
- Accept with `Tab` or tweak as needed.
201+
202+
#### 3. **Copilot Chat (If Installed)**
203+
- **Open Chat**:
204+
- Click the chat icon in the sidebar or use `Ctrl+Alt+C` (customizable).
205+
- **Ask Questions**:
206+
- Type something like “Explain how Promises work in JavaScript” or “Write a Python script to read a CSV file.”
207+
- Copilot will respond in the chat panel and can insert code directly into your editor.
208+
- **Contextual Help**:
209+
- Highlight code, right-click, and select “Ask Copilot” to explain or refactor it.
210+
211+
#### 4. **Debugging and Testing**
212+
- Write a comment like `// Write unit tests for this function`, and Copilot can generate test cases using frameworks like Jest or PyTest.
213+
214+
---
215+
216+
### Tips for Effective Use
217+
- **Be Specific**: The more context you provide (e.g., comments, variable names), the better Copilot’s suggestions.
218+
- **Review Suggestions**: Copilot isn’t perfect—always check its code for accuracy and security.
219+
- **Language Support**: It works best with popular languages (Python, JavaScript, Java, etc.) but supports dozens more.
220+
- **Keyboard Shortcuts**:
221+
- `Alt+\` (or `Option+\` on Mac): Show all suggestions manually.
222+
- `Ctrl+Enter`: Open the suggestion panel.
223+
224+
---
225+
226+
### Troubleshooting
227+
- **Not Working?**:
228+
- Ensure you’re signed in (check the status bar).
229+
- Verify your subscription is active in your GitHub account settings.
230+
- Restart VS Code or reinstall the extension if issues persist.
231+
- **No Suggestions?**:
232+
- Check if Copilot is enabled for the current language (`editor.inlineSuggest.enabled` should be true in settings).
233+
234+
---
235+
121236
That’s it! You’re now ready to use GitHub Copilot in VS Code. Start by opening a file, typing some code or a comment, and let Copilot assist you. Enjoy coding smarter!

0 commit comments

Comments
 (0)