Now, in the previous lecture, I did paste some code into this chat box here when asking
a question regarding how this code could be optimized.
Now, you actually don't have to do that.
If I open a new chat, which I can by pressing the plus button here, by the way, I could
have also added a follow-up question to the old chat, but now I want to start a new chat.
If I do that, then I can again ask this question, how can I optimize the code?
But this time I won't paste in any code snippet.
Because let's say I want to optimize the entire file and ask about the code of this
entire file.
Now, if I send this question like this, it does indeed automatically evaluate this file
which I currently have open.
And depending on when you're watching this, it might even evaluate other files in your
project.
That is possible.
But if it wouldn't do that, if I open another new chat, how can I optimize this code?
I could also add an explicit file reference here to tell GitHub Copilot Chat which code
I mean.
You can do this by adding context by pressing this button here.
And then you see I could select code base here or a current editor to refer to the currently
open editor.
I could use selection.
If I had some code selected here, I could use selection to refer to this code.
Symbol to refer to a specific symbol.
I'll get back to that.
I could refer to the last command I ran in the terminal or to any selection I have in
the terminal.
And then here I also got some files suggested so that I can ask about these files.
Though I can also do this by choosing symbol or by typing a hash manually and then the
file name.
So in my case here, dbBackup.
Alternatively, I could also choose symbol or type a hash symbol manually.
And then I can select functions from my file or choose the entire file here.
I can also type file and then get a suggestion of the files I could choose.
I could also choose symbol or type a hash manually and then I can ask questions about
specific functions or variables from my file.
So I can do that too.
Alternatively, here in the chat box, you can also enter a hash symbol and then you can
use these shortcuts here to refer to your entire code base, to your editor or to a specific
file by typing hash tag file and then choose one of the files like dbBackup.
And you see this now gets added like this here to the code editor.
So there are different ways of referring to different parts of your project to the entire
code base.
So to all your files with all your code to a specific file and so on.
So that would be another more explicit way of referring to this specific dbBackup py
file.
We can then ask the same question to get an answer regarding how this code could be optimized.
For example, to remove redundant logging, combine exception handling.
And again, I get a little suggestion here, which I could apply to improve my code.
And that shows you the strength of this chat feature.
You can ask anything about your code, for example, about general ways of improving it.
And you can refer to specific parts of your code or to specific files to make sure that
this chat has just the right context to answer your question in hopefully the best possible
way.