Skip to content

Commit 67c7f0f

Browse files
authored
Merge pull request #41 from oscarlevin/copilot
write first draft of copilot section
2 parents 36552c7 + 921cc3b commit 67c7f0f

4 files changed

Lines changed: 153 additions & 1 deletion

File tree

77.9 KB
Loading

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# <!-- Managed automatically by PreTeXt authoring tools -->
2-
pretext == 2.10.1
2+
pretext == 2.11.3

source/ch-copilot.ptx

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<chapter xml:id="ch-copilot" xmlns:xi="http://www.w3.org/2001/XInclude">
4+
<title>Copilot and Other AI Assistants</title>
5+
6+
<introduction>
7+
<p>
8+
In this chapter we will explore GitHub's <term>Copilot</term> features, as well as how other AI assistants can be used with GitHub and VS Code.
9+
</p>
10+
11+
<p>
12+
Note that almost everything in this chapter will likely be out of date almost immediately.
13+
The current suggestions here are up to date as of <strong>2025-01-08</strong>.
14+
</p>
15+
</introduction>
16+
17+
<section xml:id="sec-options">
18+
<title>AI Assistant Options</title>
19+
20+
<p>
21+
<term>Copilot</term> is GitHub's AI assistant, tightly integrated with GitHub and VS Code through a pair of extensions. There is currently a free tier that allows for a limited number of interactions each month, as well as a $10/month plan that provides unlimited interactions with Copilot (there is a free trial of the paid version as well).
22+
</p>
23+
24+
<p>
25+
Depending on what you want to do with your project, other AI assistants might be a better fit.
26+
One notable alternative that might work even better for coding projects is <url href="https://codeium.com">Codeium</url>.
27+
In particular, Codeium has a free tier that appears to offer unlimited interactions.
28+
Like Copilot, Codeium also works with VS Code through an extension and the two use similar interfaces, so it should be relatively easy to switch between the two.
29+
</p>
30+
31+
<p>
32+
All of the specific commands described below will be those of Copilot, but often the same commands will work with Codeium.
33+
In any event, we will focus on general principles of how to use these coding assistants.
34+
</p>
35+
</section>
36+
37+
<section xml:id="sec-setup">
38+
<title>Setup</title>
39+
40+
<p>
41+
We will assume you want to use Copilot from inside VS Code, either on your own machine or in a Github Codespace.
42+
To get set up, follow the <url href="https://docs.github.com/en/copilot/quickstart?tool=vscode">Quick Start Guide</url> from the Copilot documentation.
43+
</p>
44+
45+
<p>
46+
In particular, make sure you have
47+
<ul>
48+
<li>
49+
<p>
50+
Enabled Copilot in your Github account.
51+
</p>
52+
</li>
53+
54+
<li>
55+
<p>
56+
Installed the Copilot extension in VS Code.
57+
</p>
58+
</li>
59+
</ul>
60+
</p>
61+
62+
<p>
63+
That should be it.
64+
</p>
65+
</section>
66+
67+
<section xml:id="sec-copilot-features">
68+
<title>Features</title>
69+
70+
<p>
71+
There are three main ways you can interact with Copilot from inside VS Code:
72+
<ol>
73+
<li>
74+
<p>
75+
By accepting <q>ghost text</q> suggestions as you type.
76+
Copilot will will show you the most likely words to appear next to your cursor in light gray text.
77+
Hitting <c>TAB</c> will accept the current suggestion in full; <c>CTRL+RightArrow</c> will accept one word at a time.
78+
</p>
79+
</li>
80+
81+
<li>
82+
<p>
83+
Use Copilot Chat by clicking the Copilot icon at the top of the VS Code window, right of the search bar (see <xref ref="copilot-icon"/>).
84+
Select <q>Open chat</q> to open a panel on the right side of the window.
85+
This panel allows you to <q>Ask Copilot</q> questions, similar to using ChatGPT or another AI chatbot.
86+
The key difference is that Copilot uses your current file or workspace (or another selected source) as its context.
87+
You can also use voice commands to ask questions and have Copilot read its answers aloud.
88+
</p>
89+
</li>
90+
91+
<li>
92+
<p>
93+
By using Copilot's <term>inline chat</term>.
94+
While typing in the editor, or with a selection highlighted, you can use <c>CTRL+I</c> to get a floating chat window that can provide suggestions based on your cursor position or the current selection.
95+
You can accept or discard edits suggested by copilot easily from this interface.
96+
</p>
97+
</li>
98+
</ol>
99+
</p>
100+
101+
<figure xml:id="copilot-icon">
102+
<caption>The copilot icon at the top of VS Code.</caption>
103+
<image source="screenshots/copilot-icon.png">
104+
<shortdescription>
105+
screenshot of vs code with the copilot icon clicked.
106+
</shortdescription>
107+
</image>
108+
</figure>
109+
</section>
110+
111+
<section xml:id="sec-things-to-try">
112+
<title>Things to Try</title>
113+
114+
<p>
115+
Here are a few features of Copilot you might want to try out.
116+
<ul>
117+
<li>
118+
<p>
119+
Suppose you are trying to write some code in a language you are not that familiar with. Copilot will suggest the next bit of code for you as you type. To get better suggestions, put in a comment describing what you want to do. (Hint: if you don't know the syntax for comments, hit <c>CTRL+/</c> to start a comment in most languages.)
120+
</p>
121+
</li>
122+
<li>
123+
<p>
124+
Does the code do what you want it to? Is it confusing? Ask Copilot to <em>explain</em> the code to you. You can select the code, hit <c>CTRL+I</c>, and then type <c>/explain</c> (note the forward slash).
125+
</p>
126+
</li>
127+
<li>
128+
<p>
129+
Along these lines, try asking Copilot to document your code for you. Select the code, hit <c>CTRL+I</c>, and then type <c>/doc</c>.
130+
</p>
131+
</li>
132+
<li>
133+
<p>
134+
Here is something I just did while writing this. I realized that I wanted all the keyboard shortcuts to be displayed as code, which in <pretext /> is done by enclosing them in <tag>c</tag> tags. So I selected the entire document, hit <c>CTRL+I</c> and typed <q>wrap all keyboard shortcuts here with <tag>c</tag> tags.</q> Copilot then let me see where it made changes (line by line) and let me accept them or not.
135+
</p>
136+
<p>
137+
A very new Copilot feature is <term>Copilot Edits</term>, which allow you to do such things for multiple files at the same time. I suspect this could also be useful for finding typos.
138+
</p>
139+
</li>
140+
<li>
141+
<p>
142+
If you are working on a mathematical proof or a complex equation, you can ask Copilot to help you format it correctly in LaTeX. Simply type your equation or proof in plain text, select it, hit <c>CTRL+I</c>, and ask Copilot to convert it to LaTeX. This can save you a lot of time and ensure that your mathematical notation is accurate.
143+
</p>
144+
<p>
145+
NOTE: I don't know if that's true, the above paragraph was generated by Copilot from the prompt <q>Write a suggestion of something Copilot can do for a mathematician.</q>
146+
</p>
147+
</li>
148+
</ul>
149+
</p>
150+
</section>
151+
</chapter>

source/main.ptx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<xi:include href="ch-first-repo.ptx"/>
2222
<xi:include href="ch-coding.ptx"/>
2323
<xi:include href="ch-website.ptx"/>
24+
<xi:include href="ch-copilot.ptx"/>
2425
<xi:include href="ch-collaboration.ptx"/>
2526
<xi:include href="ch-jupyter.ptx"/>
2627
<xi:include href="ch-projects.ptx"/>

0 commit comments

Comments
 (0)