{"id":32991,"date":"2025-01-30T11:32:31","date_gmt":"2025-01-30T06:02:31","guid":{"rendered":"https:\/\/codeforgeek.com\/?p=32991"},"modified":"2025-01-30T17:08:23","modified_gmt":"2025-01-30T11:38:23","slug":"using-github-copilot-in-vs-code","status":"publish","type":"post","link":"https:\/\/codeforgeek.com\/using-github-copilot-in-vs-code\/","title":{"rendered":"A Guide to Using GitHub Copilot in VS Code (With Video)"},"content":{"rendered":"\n<figure class=\"wp-block-embed alignright is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe title=\"GitHub Copilot is really amazing!\" width=\"563\" height=\"1000\" src=\"https:\/\/www.youtube.com\/embed\/WiCIAOWIcc8?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>If you are new to programming or experienced in development you might have encountered GitHub Copilot. Copilot uses artificial intelligence to save you time when writing code. This virtual assistant system suggests coding blocks and completes your lines while writing entire functional sections. This article shows you how to use Copilot within VS Code by following simple instructions. Our guide will start basic to help both newcomers and experienced users learn Copilot through clear examples and basic code samples.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is GitHub Copilot?<\/h2>\n\n\n\n<p>GitHub Copilot is a code completion tool that GitHub built with OpenAI technology. It uses machine learning to study your code and gives recommendations as you type. It helps you work effectively both with basic functions and challenging code problems.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Visual Studio Code (VS Code):<\/strong> This is the code editor where Copilot works. You can download it from <a href=\"https:\/\/code.visualstudio.com\/\" target=\"_blank\" rel=\"noopener\">here<\/a>.<\/li>\n\n\n\n<li><strong>GitHub Account:<\/strong> We will need a GitHub account to use Copilot. If you don\u2019t have one, sign up <a href=\"https:\/\/github.com\/\" target=\"_blank\" rel=\"noopener\">here<\/a>.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Install the GitHub Copilot Extension<\/h2>\n\n\n\n<p>Visual Studio Code requires the installation of Copilot&#8217;s extension before we can use it. Here\u2019s how we can do that:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open Visual Studio Code.<\/li>\n\n\n\n<li>Access the Extensions Marketplace through two methods: Click the Extensions icon in the left Activity Bar or use the keyboard shortcut <strong><em>Control + Shift + X (Windows\/Linux users)<\/em><\/strong> or<strong><em> Command + Shift + X (macOS).<\/em><\/strong><\/li>\n\n\n\n<li>Type GitHub Copilot in the search field.<\/li>\n\n\n\n<li>After finding the GitHub Copilot extension in results click the Install button.<\/li>\n\n\n\n<li>Install Copilot extension.<\/li>\n\n\n\n<li>After a successful installation, the Copilot extension is ready to use.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img decoding=\"async\" width=\"1024\" height=\"456\" src=\"https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/image-10-1024x456.png\" alt=\"GitHub Copilot Extension\" class=\"wp-image-32993\" srcset=\"https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/image-10-1024x456.png 1024w, https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/image-10-300x134.png 300w, https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/image-10-768x342.png 768w, https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/image-10-1536x684.png 1536w, https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/image-10.png 1595w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Sign In to GitHub for GitHub Copilot<\/h2>\n\n\n\n<p>Our next step after adding the Copilot extension is to authenticate our GitHub account. Here\u2019s how:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Click the Copilot icon that appears on the left side of your screen window.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><img decoding=\"async\" width=\"301\" height=\"618\" src=\"https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/image-11.png\" alt=\"Sign In to GitHub for GitHub Copilot Step 1\" class=\"wp-image-32995\" style=\"width:232px;height:auto\" srcset=\"https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/image-11.png 301w, https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/image-11-146x300.png 146w\" sizes=\"(max-width: 301px) 100vw, 301px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The system displays a login screen to connect with GitHub. Click Sign In.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><img decoding=\"async\" width=\"391\" height=\"97\" src=\"https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/image-12.png\" alt=\"Sign In to GitHub for GitHub Copilot Step 2\" class=\"wp-image-32996\" style=\"width:327px;height:auto\" srcset=\"https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/image-12.png 391w, https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/image-12-300x74.png 300w\" sizes=\"(max-width: 391px) 100vw, 391px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Click on the on-screen prompts to confirm our GitHub account login. During this process we need to open GitHub and let VS Code use our account.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><img decoding=\"async\" width=\"638\" height=\"649\" src=\"https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/image-13.png\" alt=\"Sign In to GitHub for GitHub Copilot Step 3\" class=\"wp-image-32997\" style=\"width:398px;height:auto\" srcset=\"https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/image-13.png 638w, https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/image-13-295x300.png 295w\" sizes=\"(max-width: 638px) 100vw, 638px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The Copilot tool turns on automatically when we log into our account. Our developer work environment is ready for Copilot use. As we type in the code editor Copilot offers smart suggestions to help us write code more quickly.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><img decoding=\"async\" width=\"810\" height=\"675\" src=\"https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/image-14.png\" alt=\"Sign In to GitHub for GitHub Copilot Step 4\" class=\"wp-image-32998\" style=\"width:593px;height:auto\" srcset=\"https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/image-14.png 810w, https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/image-14-300x250.png 300w, https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/image-14-768x640.png 768w\" sizes=\"(max-width: 810px) 100vw, 810px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">GitHub Copilot Suggestions<\/h2>\n\n\n\n<p>If Copilot suggestions do not appear on it&#8217;s own, we can trigger them using <strong>Ctrl+Space<\/strong> or <strong>Alt+Enter.<\/strong> Here\u2019s how we can interact with Copilot:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Accept a Suggestion:<\/strong> Press the <strong>Tab<\/strong> key to choose the suggestion.<\/li>\n\n\n\n<li><strong>Reject a Suggestion:<\/strong> To reject the suggestion simply press <strong>Esc.<\/strong><\/li>\n\n\n\n<li>Press&nbsp;<strong>Alt + ]<\/strong>&nbsp;(Windows\/Linux) or&nbsp;<strong>Option + ]<\/strong>&nbsp;(macOS) to cycle through alternative suggestions.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">How to Use GitHub Copilot in Visual Studio Code<\/h2>\n\n\n\n<p>Now that Copilot is set up, let\u2019s explore how it works with some beginner-friendly examples.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Example 1:<\/h3>\n\n\n\n<p>Suppose we want to write a function that adds two numbers. Here\u2019s how Copilot can assist us:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Start typing the following code:<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\ndef add_numbers(a, b):\n<\/pre><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li>The moment you start typing the function name, Copilot will suggest the rest of the code. We can press&nbsp;<strong>Tab&nbsp;<\/strong>to accept the suggestion.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img decoding=\"async\" width=\"192\" height=\"44\" src=\"https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/image-22.png\" alt=\"Example 1\" class=\"wp-image-33007\"\/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Copilot finished creating our function to save us labor and time.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img decoding=\"async\" width=\"201\" height=\"43\" src=\"https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/image-21.png\" alt=\"Example 1 Output\" class=\"wp-image-33006\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Example 2:<\/h3>\n\n\n\n<p>Let\u2019s try another example. Suppose we want to create a list of squares.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n# Create a list of squares\nsquares = &#x5B;\n<\/pre><\/div>\n\n\n<p>Copilot will suggest the next line.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img decoding=\"async\" width=\"328\" height=\"66\" src=\"https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/image-23.png\" alt=\"Example 2\" class=\"wp-image-33008\" srcset=\"https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/image-23.png 328w, https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/image-23-300x60.png 300w\" sizes=\"(max-width: 328px) 100vw, 328px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img decoding=\"async\" width=\"364\" height=\"52\" src=\"https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/image-18.png\" alt=\"Example 2 Output\" class=\"wp-image-33002\" srcset=\"https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/image-18.png 364w, https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/image-18-300x43.png 300w\" sizes=\"(max-width: 364px) 100vw, 364px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Example 3:<\/h3>\n\n\n\n<p>Copilot helps us find and solve problems in our programming code. When our code produces an error it can provide us with a suggested solution.<\/p>\n\n\n\n<p>Consider the following code with an error:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\ndef divide(a, b):\n    return a \/ b\n\nresult = divide(10, 0)\nprint(result\nif b == 0:\n<\/pre><\/div>\n\n\n<p>Copilot might suggest adding a check to avoid division by zero:<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><img decoding=\"async\" width=\"286\" height=\"212\" src=\"https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/image-24.png\" alt=\"Example 3 \" class=\"wp-image-33009\" style=\"width:247px;height:auto\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><img decoding=\"async\" width=\"365\" height=\"189\" src=\"https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/image-25.png\" alt=\"Example 3 Output\" class=\"wp-image-33010\" style=\"width:295px;height:auto\" srcset=\"https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/image-25.png 365w, https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/image-25-300x155.png 300w\" sizes=\"(max-width: 365px) 100vw, 365px\" \/><\/figure>\n\n\n\n<p>Our code quality improves when Copilot provides assistance. Now, you might wonder what those little stars out there are. Clicking on them opens a quick fix window, allowing you to add Copilot chat assistance within your code.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><img decoding=\"async\" width=\"254\" height=\"133\" src=\"https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/image-26.png\" alt=\"Copilot Chat Assistance \" class=\"wp-image-33011\" style=\"width:204px;height:auto\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><img decoding=\"async\" width=\"820\" height=\"243\" src=\"https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/image-27.png\" alt=\"Copilot Chat Assistance Output\" class=\"wp-image-33012\" style=\"width:537px;height:auto\" srcset=\"https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/image-27.png 820w, https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/image-27-300x89.png 300w, https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/image-27-768x228.png 768w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Limitations of GitHub Copilot<\/h2>\n\n\n\n<p>While Copilot is a powerful tool, it is important to be aware of its limitations:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Not Always Accurate:<\/strong> Copilot generates output that relies on current codebases and may not produce the most refined secure options.<\/li>\n\n\n\n<li><strong>Limited Context Awareness:<\/strong> Copilot needs a complete understanding of our project to deliver appropriate recommendations.<\/li>\n\n\n\n<li><strong>Dependency on the Internet:<\/strong> Copilot needs an ongoing Internet connection to operate.<\/li>\n<\/ul>\n\n\n\n<p>We need to verify suggestions by checking them against our projects before using them.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>GitHub Copilot brings powerful new features to help us work better with our code. Copilot saves us time by handling routine tasks and suggesting smart ideas so we can tackle difficult problems and produce better code. Using this guide helps us easily add Copilot to our work routine and make the most of its features. Copilot serves to support our work rather than take our place.<\/p>\n\n\n\n<p>Since you seem interested in extensions, <a href=\"https:\/\/codeforgeek.com\/10-best-ai-powered-chrome-extensions-to-save-your-time\/\">click here<\/a> to learn about the best Chrome extensions to speed up your work.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you are new to programming or experienced in development you might have encountered GitHub Copilot. Copilot uses artificial intelligence to save you time when writing code. This virtual assistant system suggests coding blocks and completes your lines while writing entire functional sections. This article shows you how to use Copilot within VS Code by [&hellip;]<\/p>\n","protected":false},"author":104,"featured_media":33014,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_surecart_dashboard_logo_width":"180px","_surecart_dashboard_show_logo":true,"_surecart_dashboard_navigation_orders":true,"_surecart_dashboard_navigation_invoices":true,"_surecart_dashboard_navigation_subscriptions":true,"_surecart_dashboard_navigation_downloads":true,"_surecart_dashboard_navigation_billing":true,"_surecart_dashboard_navigation_account":true,"_uag_custom_page_level_css":"","footnotes":""},"categories":[444],"tags":[],"class_list":["post-32991","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ai"],"blocksy_meta":[],"uagb_featured_image_src":{"full":["https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/copilot.png",1200,600,false],"thumbnail":["https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/copilot-150x150.png",150,150,true],"medium":["https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/copilot-300x150.png",300,150,true],"medium_large":["https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/copilot-768x384.png",768,384,true],"large":["https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/copilot-1024x512.png",1024,512,true],"1536x1536":["https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/copilot.png",1200,600,false],"2048x2048":["https:\/\/codeforgeek.com\/wp-content\/uploads\/2025\/01\/copilot.png",1200,600,false]},"uagb_author_info":{"display_name":"Snigdha Keshariya","author_link":"https:\/\/codeforgeek.com\/author\/snigdha\/"},"uagb_comment_info":0,"uagb_excerpt":"If you are new to programming or experienced in development you might have encountered GitHub Copilot. Copilot uses artificial intelligence to save you time when writing code. This virtual assistant system suggests coding blocks and completes your lines while writing entire functional sections. This article shows you how to use Copilot within VS Code by&hellip;","_links":{"self":[{"href":"https:\/\/codeforgeek.com\/wp-json\/wp\/v2\/posts\/32991","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codeforgeek.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codeforgeek.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codeforgeek.com\/wp-json\/wp\/v2\/users\/104"}],"replies":[{"embeddable":true,"href":"https:\/\/codeforgeek.com\/wp-json\/wp\/v2\/comments?post=32991"}],"version-history":[{"count":0,"href":"https:\/\/codeforgeek.com\/wp-json\/wp\/v2\/posts\/32991\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codeforgeek.com\/wp-json\/wp\/v2\/media\/33014"}],"wp:attachment":[{"href":"https:\/\/codeforgeek.com\/wp-json\/wp\/v2\/media?parent=32991"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codeforgeek.com\/wp-json\/wp\/v2\/categories?post=32991"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codeforgeek.com\/wp-json\/wp\/v2\/tags?post=32991"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}