GitHub Copilot in VSCode: Explaining the Basics

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
GitHub copilot has become one of the most popular extensions for VSS code and that is no surprise because GitHub co-pilot allows you to code much faster than you would usually code by giving you AI based suggestions in this video I'm going to cover the most important stuff that most firsttime users are not going to be aware of if you stick around until the end then you will know that you will be making the most out of this extension so let's get right in if you have not yet downloaded the extensions you simply want to go to the extensions tab search for GitHub copilot and once it appears simply click on the extension and then on install to use GitHub copilot you need to have your GitHub account linked if that is not the case then a small prompt will appear in the bottom right hand corner telling you that you need to sign in to GitHub so click your way through the sign up process and once you've done that GitHub co-pilot will be ready to use if you're unsure whether or not GitHub co-pilot is configured and working correctly you can go ahead and simply press on the co-pilot icon down here and a popup will open from the top telling you the status and currently you can see that the status is ready so it's ready to use let's start really simple and ask GitHub co-pilot a simple question you can see that in this blank test. Json file there is already a line written by GitHub copilot it comes right after you install the extension and it says press control I to ask GitHub copile to do something so when I press that on my keyboard I get this small line that opens up that allows me to put in a prompt into my editor so let's go ahead and put in something like make a function that concatenates two strings and we can simply send that by pressing enter and you will see that I subsequently get a function written in the editor that takes two strings as parameters and Returns the concatenated value if I like the suggestion that GitHub copilot has made I can simply accept it and it will remain in my editor GitHub copilot also allows me to make adjustments to the code that is written in the editor so if I go ahead and highlight the code and rightclick and then go on co-pilot and start inline chat which I can also open up using contr I as we did earlier I can now make amendments to the highlighted code by simply writing something into the line again so let's go ahead and say add another string input and send that using enter and you'll see that we have the code changes sort of stacked next to one another so you can see on the right hand side we have three string values that are now being in catenated and I do like these changes but instead of pressing accept straight away let's go ahead and press on this down arrow icon next to discard over here you can see that I have the options to completely discard the changes to copy them to a clipboard or to discard them to a new file so let's go ahead and discard them to the clipboard and you'll see that if I go ahead and press control V I can go ahead and paste the changes that were suggested a moment ago another really helpful thing is that GitHub co-pilot detects what you're writing and automatically makes suggestions for your code so if I go ahead and make a comment by writing two forward slashes and then writing something along the lines of a function that calculates the days between two dates and you can see that while typing the end of the sentence that I'm trying to type is already being suggested to me by GitHub copilot because it has a slightly different shade of gray now I can simply press Tab and accept that and it will add the words below that I can start my function definition by simply writing function and pretty much instantaneously GitHub co-pilot is going to come up with a code suggestion now sometimes GitHub co-pilot comes up with multiple suggestions if you want to see them all you simply need to hover your mouse over the suggested code and you'll see a small popup appear or you can toggle through the individual suggestions sometimes you might want to see all the suggestions at once in that case you simply need to press control and enter and you'll get a new file that compiles all the individual suggestions in one file now another thing that I want to show you is how you can ask questions that don't specifically relate to the code that you wrote for example let's say that you want to ask how you can call a function in JavaScript to do that you can open the chat window by pressing contrl shift and I and then you can proceed to ask your questions so how do I call a function in JavaScript and you'll see that GitHub copilot is going to give you an answer to your question and if you prefer to have the chat window open next to your code you can either press on this small chat icon or you can press on the chat icon on the top of the window over here and this will open the side bar the next thing I want to show you is how GitHub co-pilot can explain some code for you so we're going to take one of the suggestions from the right hand side and we're simply going to paste it into the test.js file now the next thing that I'm going to do is I'm going to highlight the code that I just pasted in I'm going to right click on it and then in co-pilot I'm going to write uh go ahead and click on explain this and once I do that you can see the sidebar open opens up and it goes ahead and explains the code that I have highlighted which is super helpful the last final fun fact that I want to show you is that when you go to the source control and you've made some changes to one of your project you can simply generate a commit message without having to write one yourself so right here I have a project that I'm currently working on and you can see that I have a couple of changes now over here you can see that the commitment message is empty but when I press on these two star icons it analyzes the changes that I've made and it writes a commit message for you so I'm going to leave it here for this video If it helped you out then make sure to support me by subscribing and liking this video see you in the next one
Info
Channel: Max on Tech
Views: 2,312
Rating: undefined out of 5
Keywords: Github, Github Copilot, ChatGPT VSCode, VSCode, Copilot, AI
Id: q0PorpN6SQM
Channel Id: undefined
Length: 6min 47sec (407 seconds)
Published: Mon Dec 25 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.