Skip to content

Commit f1f8920

Browse files
committed
Update Copilot Getting Started
1 parent b29cedf commit f1f8920

8 files changed

+71
-45
lines changed

docs/copilot/getting-started.md

Lines changed: 56 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -28,99 +28,89 @@ Follow these steps to [set up GitHub Copilot in VS Code](/docs/copilot/setup.md)
2828

2929
## Get your first code suggestion
3030

31-
Now that you've signed up for Copilot and activated the extension, let's see its assistance in action!
32-
3331
To get started with GitHub Copilot in VS Code, you don't have to do anything special. As you're typing code in the editor, Copilot automatically presents you code suggestions in the editor to help you code more efficiently.
3432

35-
1. Open Visual Studio Code and create a new TypeScript file `Calculator.ts`.
33+
1. Open Visual Studio Code and create a new JavaScript file `calculator.js`.
3634

37-
1. In the TypeScript file, start typing the following class definition.
35+
1. In the JavaScript file, start typing the following code:
3836

39-
```typescript
37+
```javascript
4038
class Calculator
4139
```
4240

43-
Copilot automatically suggests a method for our `Calculator` class in gray dimmed text (ghost text). In our example, the `add` method is suggested. The exact suggestions can vary.
41+
Copilot automatically suggests a method for our `Calculator` class in gray dimmed text (ghost text). In our example, the `add` and `subtract` methods are suggested. The exact suggestions you receive might vary.
4442

4543
![Screenshot of VS Code editor, showing Copilot suggesting the `add` method inside the `Calculator` class.](./images/getting-started/copilot-code-completion.png)
4644

4745
1. To accept the suggestion, press the `kbstyle(Tab)` key.
4846

4947
Congratulations! You've just accepted your first AI-powered inline suggestion. As you continue typing, Copilot updates the inline suggestion accordingly.
5048
51-
1. For any given input, there might be multiple suggestions. Type the following inside the class to add a `fibonacci` method:
49+
1. For any given input, there might be multiple suggestions. Type the following code inside the class to add a `factorial` method:
5250
53-
```typescript
54-
fibonacci(n: number): number {
51+
```javascript
52+
factorial(n) {
5553
```
5654
5755
1. Hover over the suggestion in the editor and notice that there are multiple suggestions.
5856
59-
![Screenshot of VS Code editor, showing Copilot giving multiple suggestions for `fibonacci` when hovering over it.](./images/getting-started/copilot-code-completion-multiple.png)
57+
![Screenshot of VS Code editor, showing Copilot giving multiple suggestions for `factorial` when hovering over it.](./images/getting-started/copilot-code-completion-multiple.png)
6058
6159
You can use the arrow controls or use the keybindings to show the next (`kb(editor.action.inlineSuggest.showNext)`) or previous (`kb(editor.action.inlineSuggest.showPrevious)`) suggestion.
6260
6361
AI-powered code completions can help you with generating boilerplate or repetitive code, letting you stay in the developer flow and focus on more complex coding tasks.
6462
65-
## Generate a simple web server with Copilot Chat
63+
## Use Inline Chat to generate a basic web server
6664
67-
With the [Copilot Chat](https://marketplace.visualstudio.com/items?itemName=GitHub.copilot-chat) extension, you can start a chat conversations with Copilot in VS Code to ask specific tasks about your code by using natural language.
65+
With Copilot Chat, you can start a chat conversation with Copilot in VS Code to ask specific tasks about your code by using natural language.
6866
69-
Let's use Copilot Chat to help us generate a simple Express web server.
67+
Let's use **Inline Chat** to help generate a basic Express web server.
7068

7169
1. First, add a new TypeScript file `server.ts` to your workspace.
7270

73-
Let's use the Copilot Inline Chat in the editor to generate a simple Express web server.
74-
7571
1. Now, press `kb(inlinechat.start)` on your keyboard to bring up Copilot Inline Chat.
7672

77-
With Copilot Inline Chat you get a chat interface that lets you ask questions about your code by using natural language.
73+
Copilot Inline Chat gives you a chat interface that lets you ask questions about the code in the active editor.
7874

7975
![Screenshot of VS Code editor, showing the Copilot Inline Chat control.](./images/getting-started/copilot-inline-chat.png)
8076

81-
1. Type *"add a simple express web server"* in the chat input field, and press `kbstyle(Enter)` to send the chat request or prompt to Copilot.
77+
1. Type *"add a simple express web server"* in the chat input field, and press `kbstyle(Enter)` to send the prompt to Copilot.
8278

83-
Notice that Copilot returns a streaming response into the editor. The response is an implementation for a simple Node.js Express web server.
79+
Notice that Copilot returns a streaming response in the editor. The response is an implementation for a simple Node.js Express web server.
8480

8581
![Screenshot of VS Code editor, showing the Copilot Inline Chat response for adding an Express web server.](./images/getting-started/copilot-inline-chat-express-server.png)
8682

8783
1. Select **Accept** or press `kb(inlineChat.acceptChanges)` to apply the proposed code changes.
8884

8985
Congratulations! You've used Copilot Chat for generating code using chat and natural language.
9086
91-
Now, let's use Copilot Chat to help us refactor our code and return a static HTML file when users navigate to the home page.
92-
9387
## Refactor your code through AI chat
9488
95-
As you work on an existing codebase, you often need to refactor or improve existing code. You'll use Copilot Chat to refactor and iterate over your code.
89+
You can also use Inline Chat to refactor or improve existing code in the editor.
9690
97-
Let's update the `/` route to return a static HTML page.
91+
Notice that our web server is currently using a static port number `3000`. Let's change this to use an environment variable for the port number.
9892

99-
1. In the editor, select the `app.get('/', req, res)` method, and then press `kb(inlinechat.start)` to start Inline Chat.
93+
1. In the editor, select the `3000` port number in the `server.ts` file, and then press `kb(inlinechat.start)` to start Inline Chat.
10094

101-
By selecting a range of text in the editor, you provide more context to Copilot about your request.
95+
1. Type *"use an environment variable for the port number"* in the chat input field, and press `kbstyle(Enter)` to send the chat request or prompt.
10296

103-
1. Type *"return a static index.html file"* in the chat input field, and press `kbstyle(Enter)` to send the chat request or prompt.
97+
Notice how Copilot updates the existing code to use an environment variable for the port number.
10498

105-
Notice how Copilot updates the existing method implementation to return an `index.html` file.
106-
107-
![Screenshot of VS Code editor, showing the Copilot Inline Chat suggested changes, highlighting the `Show changes` button.](./images/getting-started/copilot-inline-chat-refactor.png)
99+
![Screenshot of VS Code editor, showing Inline Chat to use an environment variable for the port number.](./images/getting-started/copilot-inline-chat-refactor-port.png)
108100

109101
1. Select **Accept** or press `kb(inlineChat.acceptChanges)` to apply the proposed code changes.
110102

111-
Experiment further with Copilot Chat, for example to use an environment variable for the port number, to add more routes to your web server, or ask Copilot Chat to add error handling, and more.
112-
113-
![Screenshot of VS Code editor, showing the Copilot Inline Chat to use an environment variable for the port number.](./images/getting-started/copilot-inline-chat-refactor-port.png)
103+
1. If you're not happy with a proposed change, you can modify the prompt and ask Copilot to provide a different solution.
114104
115-
With Copilot Chat you can use a chat conversation and natural language to direct Copilot to perform specific tasks on your codebase. With Inline Chat, you can stay in the flow of coding, and ask for AI assistance in the moment, when you need it, without switching context.
105+
For example, you can ask Copilot to use a different environment variable name for the port number.
116106
117107
## Use Copilot Chat for general programming questions
118108
119109
As you're working in a new codebase, or exploring a new programming language, you might have more general coding questions come up. Copilot Chat lets you open a chat conversation on the side, and which keeps track of the history of your questions.
120110

121-
1. Open the Chat view from the Command Center chat menu or press `kb(workbench.action.chat.open)`.
111+
1. Open the Chat view from the Command Center Copilot menu or press `kb(workbench.action.chat.open)`.
122112

123-
![Screenshot of VS Code editor, showing the Copilot Chat view, highlighting the chat menu in the Command Center.](./images/getting-started-chat/command-center-open-chat.png)
113+
![Screenshot of VS Code editor, showing the Copilot Chat view, highlighting the Copilot menu in the Command Center.](./images/getting-started-chat/command-center-open-chat.png)
124114

125115
> [!TIP]
126116
> You can access different Copilot features from the Command Center menu at any time.
@@ -131,6 +121,34 @@ As you're working in a new codebase, or exploring a new programming language, yo
131121

132122
Notice how the chat response contains rich results, consisting of text and a code block. The code block in the chat response supports IntelliSense, which enables you get information about methods and symbols by hovering over them, or to go to their definition.
133123

124+
1. Follow the steps in the [Copilot Chat tutorial](/docs/copilot/getting-started-chat.md) to learn how you can also use Copilot Chat to ask questions about your specific codebase.
125+
126+
## Make edits across multiple files with Copilot Edits (preview)
127+
128+
Larger code changes might involve making edits to multiple files. With Copilot Edits, you can get AI-powered suggestions inline in the editor, across multiple files in your workspace.
129+
130+
Let's use Copilot Edits to return the contents of an HTML file in a web server response.
131+
132+
1. Select **Open Copilot Edits** from the Command Center Copilot menu or press `kb(workbench.action.chat.openEditSession)`.
133+
134+
![Screenshot showing the Copilot menu in the Command Center, highlighting the Open Edit Session item](images/copilot-edits/copilot-command-center-open-edit-session.png)
135+
136+
1. The Copilot Edits view is opened. Notice that the `server.ts` file is added to the *Working Set*.
137+
138+
The Working Set contains the files that can be modified by Copilot Edits. If the file is not added, use **Add Files...* to add the file to the Working Set.
139+
140+
![Screenshot of the Copilot Edits view, showing the Working Set with the `server.ts` file.](./images/getting-started/copilot-edits-working-set.png)
141+
142+
1. Enter *Return a static html page as the home page and implement it.* in the chat input field and press `kbstyle(Enter)` to start a new edit session.
143+
144+
Notice that Copilot Edits updates the `server.ts` file to return a static HTML page in the web server response. It also adds a new file `index.html` to the workspace.
145+
146+
![Screenshot of VS Code editor, showing the Copilot Edits response for returning a static HTML page in the web server response.](./images/getting-started/copilot-edits-html-response.png)
147+
148+
1. If you're happy with the results, select **Accept** to apply all suggested changes.
149+
150+
![Screenshot of the Copilot Edits view, highlighting the Accept button to apply the changes.](./images/getting-started/copilot-edits-accept.png)
151+
134152
## Fix coding errors with Copilot
135153

136154
Aside from inline completions and chat conversations, GitHub Copilot is available in different places and throughout your developer flow in VS Code. You might notice the presence of Copilot functionality through the *sparkle* icon in the VS Code user interface.
@@ -153,11 +171,13 @@ One such place is the Copilot coding actions in the editor, whenever there you h
153171
154172
Directly from the chat response, you can optionally select the **Insert into Terminal** button to copy the proposed command in your terminal.
155173
156-
## Congratulations
174+
## Next steps
157175
158176
Congratulations, you've now used artificial intelligence to enhance your coding! In this tutorial, you successfully set up Copilot in VS Code, and used Copilot code completions, Copilot Chat, and code actions to help you code more efficiently.
159177

160-
You've started experimenting with Copilot and there's a lot more you can do with it! To learn more about Copilot Chat, proceed to the [Copilot Chat Tutorial](/docs/copilot/getting-started-chat.md).
178+
* To learn more about Copilot Chat, proceed to the [Copilot Chat Tutorial](/docs/copilot/getting-started-chat.md).
179+
180+
* To learn more about Copilot Edits, proceed to the [Copilot Edits](/docs/copilot/copilot-edits.md) documentation.
161181

162182
## Related resources
163183

Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading

docs/copilot/images/getting-started/copilot-inline-chat-refactor.png

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)