Skip to main content

Generative AI

Mastering GitHub Copilot in VS Code

Istock 1628553826

Ready to go from “meh” to “whoa” with your AI coding assistant? Here’s how to get started.

You’ve installed GitHub Copilot. Now what?

Here’s how to actually get it to work for you – not just with you.

In the blog Using GitHub Copilot in VS Code, we have already seen how to use GitHub Copilot in VS Code.

1. Write for Copilot, Not Just Yourself

Copilot is like a teammate who’s really fast at coding but only understands what you clearly explain.

Start with Intention:

Use descriptive comments or function names to guide Copilot.

// Fetch user data from API and cache it locally
function fetchUserData() {

Copilot will often generate useful logic based on that. It works best when you think one step ahead.

2. Break Problems Into Small Pieces

Copilot shines when your code is modular.

Instead of writing:

function processEverything() {
  // 50 lines of logic
}

Break it down:

// Validate form input
function validateInput(data) {

}

// Submit form to backend
function submitForm(data) {

}

This way, you get smarter, more accurate completions.

3. Use Keyboard Shortcuts to Stay in Flow

Speed = flow. These shortcuts help you ride Copilot without breaking rhythm:

Action Shortcut (Windows) Shortcut (Mac)
Accept Suggestion Tab Tab
Next Suggestion Alt + ] Option + ]
Previous Suggestion Alt + [ Option + [
Dismiss Suggestion Esc Esc
Open Copilot Panel Ctrl + Enter Cmd + Enter

Power Tip: Hold Tab to preview full suggestion before accepting it.

4. Experiment With Different Prompts

Don’t settle for the first suggestion. Try giving Copilot:

  • Function names like: generateInvoicePDF()
  • Comments like: // Merge two sorted arrays
  • Descriptions like: // Validate email format

Copilot might generate multiple versions. Pick or tweak the one that fits best.

5. Review & Refactor – Always

Copilot is smart, but not perfect.

  • Always read the output. Don’t blindly accept.
  • Add your own edge case handling and error checks.
  • Use tools like ESLint or TypeScript for safety.

Think of Copilot as your fast-thinking intern. You still need to double-check their work.

6. Use It Across File Types

Copilot isn’t just for JS or Python. Try it in:

  • HTML/CSS → Suggest complete sections
  • SQL → Generate queries from comments
  • Markdown → Draft docs and README files
  • Dockerfiles, .env, YAML, Regex patterns

Write a comment like # Dockerfile for Node.js app – and watch the magic.

7. Pair It With Unit Tests

Use Copilot to write your test cases too:

// Test case for addTwoNumbers function
describe('addTwoNumbers', () => {

It will generate a full Jest test block. Use this to write tests faster – especially for legacy code.

8. Learn From Copilot (Not Just Use It)

Treat Copilot suggestions as learning opportunities:

  • Ask: “Why did it suggest that?”
  • Compare with your original approach
  • Check docs or MDN if you see unfamiliar code

It’s like having a senior dev whispering best practices in your ear.

9. Use Copilot Chat (If Available)

If you have access to GitHub Copilot Chat, try it. Ask questions like:

  • What does this error mean?
  • Explain this function
  • Suggest improvements for this code

It works like a Stack Overflow built into your IDE.

Quick Recap

Tip Benefit
Write clear comments Better suggestions
Break logic into chunks Modular, reusable code
Use shortcuts Stay in flow
Cycle suggestions Explore better options
Review output Avoid bugs
Test case generation Faster TDD
Learn as you go Level up coding skills

Final Thoughts: Practice With Purpose

To truly master Copilot:

  • Build small projects and let Copilot help
  • Refactor old code using Copilot suggestions
  • Try documenting your code with its help

You’ll slowly build trust – and skill.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Saket Singh, Senior Technical Consultant

Saket Singh is a Senior Technical Consultant at Perficient GDC, Nagpur, specializing in Sitecore development with a focus on SXA, Sitecore Headless, and composable DXP architectures. With over 9 years of experience in enterprise web development, Saket brings deep expertise in ASP.NET, C#, MVC, Web API, MSSQL, and JavaScript. He is passionate about exploring emerging technologies, optimizing digital experiences, and building scalable solutions that bridge marketing and technology. Outside of project delivery, Saket actively shares insights through blogs and tutorials, aiming to simplify complex concepts for developers and digital teams.

More from this Author

Follow Us