So what exactly does GitHub Copilot give us?
Chances are high that you already know some
the little tips and tricks that might be helpful to know
features you might have not heard about yet.
So here, I'm in a very basic Python project,
UV, which is simply a tool for creating
and you absolutely don't have to install it.
You don't have to follow along because we'll not build a complex project here.
Instead, we'll write some code so that I can walk you through the various
features offered by GitHub Copilot.
So a Python project it is. Now, the first thing GitHub
Copilot offers you is smart, AI-powered
autocompletion. If I, for example, introduce a variable named
Name, I'll get this suggestion here.
I have not accepted it yet, but I can hit Tab to accept it.
I can, of course, also change it. That was the AI code completion by GitHub
Copilot in action. That is actually the first feature with
started many years ago, but now it's just one of the features and
arguably not the most important ones.
Still, of course, a useful feature, which can significantly speed up
typing and writing code. What's also nice is that you don't just
get this inline smart completion, but, for
example, if I rename this function here, I'll
typically get suggestions like this one, which are so-called next
edit suggestions, where it suggests a change in a
different line of code than I was, which I can also accept with
Tab, based on the edits I made in other parts
So it tries to anticipate what I'll likely do next.
By the way, that's a feature which you can enable
GitHub Copilot thing here in the toolbar, in the status bar, and
then here, you can turn off next edit suggestions or
all AI suggestions if you don't want them.
You can also decide that on a per file or a file type basis.
Now, when Copilot gives you these suggestions,
you can of course accept them by hitting Tab, but one thing many people
don't know is you can also hover over that suggestion, and in
some cases, you'll then see different variants.
For example here, if I add a variable called Person,
I can hover over the suggestion instead of just blindly
accepting it, and it actually shows me three different
in this situation. When you're trying it, it might be different.
But here, I get three options, which are quite different.
The first one is just a different name, but then it actually wants to create a
dictionary, which stores information about a person,
And you can cycle through these options and then accept the option you want by
hitting Tab or by clicking Accept.
And you can also just accept words by clicking this button or
using this shortcut so that you can accept it step by step
that. And that, of course, can come in handy in situations where you
some AI assistance with the autocompletions, but don't want the
exact completion it's suggesting in this very moment.
What's also useful about these AI suggestions is that you can use them in
conjunction with comments. For example, if I add a comment,
"Function that combines two strings," it starts suggesting
this function for me. So you can use comments to essentially
write prompts, and that, of course, can also save you some time.
And obviously, you can then also delete the comments
function.