Skip to content

Commit 48613ce

Browse files
committed
freshness pass
1 parent 6f8f193 commit 48613ce

File tree

3 files changed

+22
-19
lines changed

3 files changed

+22
-19
lines changed
5.16 KB
Loading
155 KB
Loading

docs/get-started/tutorial-editor.md

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Introduction to editing in the code editor
33
description: Use the code editor in Visual Studio to add code to a file, and also how to write code, navigate to it, and refactor it.
4-
ms.date: 1/23/2025
4+
ms.date: 7/25/2025
55
ms.subservice: general-ide
66
ms.custom: vs-acquisition
77
ms.topic: tutorial
@@ -14,7 +14,7 @@ dev_langs:
1414
---
1515
# Learn to use the code editor
1616

17-
In this 10-minute introduction to the code editor in Visual Studio, we'll add code to a file to look at some of the ways that Visual Studio makes writing, navigating, and understanding code easier.
17+
In this introduction to the Visual Studio code editor, you’ll add code to a file and explore how Visual Studio helps make writing, navigating, and understanding code easier.
1818

1919
::: moniker range="vs-2019"
2020

@@ -33,14 +33,15 @@ This article assumes you're already familiar with a programming language. If you
3333

3434
::: moniker range=">=vs-2022"
3535

36-
> [!TIP]
37-
> To follow along with this article, make sure you have the C# settings selected for Visual Studio. For information about selecting settings for the integrated development environment (IDE), see [Select environment settings](csharp/visual-studio-ide.md#select-environment-settings).
36+
## Prerequisites
37+
38+
- Visual Studio with C# development settings configured. To configure settings, see [Select environment settings](csharp/visual-studio-ide.md#select-environment-settings).
3839

3940
::: moniker-end
4041

4142
## Create a new code file
4243

43-
Start by creating a new file and adding some code to it.
44+
Create a new file and add some code to it.
4445

4546
::: moniker range="vs-2019"
4647

@@ -64,7 +65,7 @@ Start by creating a new file and adding some code to it.
6465

6566
1. In the **New File** dialog box, under the **General** category, select **C# Class**, and then select **Open**.
6667

67-
A new file opens in the editor with the skeleton of a C# class.
68+
A new file opens in the editor with a basic C# class structure.
6869

6970
:::image type="content" source="media/vs-2022/tutorial-editor.png" alt-text="Screenshot of a C# code file in Visual Studio 2022.":::
7071

@@ -86,7 +87,7 @@ Let's use Copilot to generate code suggestions:
8687
1. GitHub Copilot generates a code suggestion for you. The suggested implementation shows in gray text.
8788
1. To accept the suggestion, select **Tab**.
8889

89-
:::image type="content" source="media/vs-2022/tutorial-editor/github-copilot-suggestions-visual-studio.gif" alt-text="Animated screenshot that shows the code suggestions generated by GitHub Copilot for the user comment." lightbox="media/vs-2022/tutorial-editor/github-copilot-suggestions-visual-studio.gif":::
90+
:::image type="content" source="media/vs-2022/tutorial-editor/github-copilot-suggestions-visual-studio.gif" alt-text="Animated screenshot that shows the code suggestions generated by GitHub Copilot for the user comment." lightbox="media/vs-2022/tutorial-editor/github-copilot-suggestions-visual-studio.gif":::
9091

9192
Let's use Copilot Chat to submit a coding-related question as a prompt:
9293

@@ -104,15 +105,15 @@ Let's use Copilot Chat to submit a coding-related question as a prompt:
104105

105106
GitHub Copilot is powered by AI, so surprises and mistakes are possible. For more information, see [GitHub Copilot FAQs](https://github.com/features/copilot#faq).
106107

107-
Get started with [GitHub Copilot in Visual Studio](../ide/visual-studio-github-copilot-install-and-states.md). Note that it requires Visual Studio 2022 version 17.8 or later.
108+
Get started with [GitHub Copilot in Visual Studio](../ide/visual-studio-github-copilot-install-and-states.md).
108109

109110
::: moniker-end
110111

111112
## Use code snippets
112113

113-
Visual Studio provides useful *code snippets* that you can use to quickly and easily generate commonly used code blocks. [Code snippets](../ide/code-snippets.md) are available for different programming languages including C#, Visual Basic, and C++.
114+
Visual Studio provides useful code snippets that you can use to quickly generate commonly used code blocks. Code snippets are available for several programming languages, including C#, Visual Basic, and C++.
114115

115-
Let's add the C# `void Main` snippet to our file.
116+
Now add the C# `void Main` snippet to your file.
116117

117118
::: moniker range="<=vs-2019"
118119

@@ -144,7 +145,7 @@ The available code snippets vary for different programming languages. You can lo
144145

145146
You'll see the `static void Main()` method signature get added to the file. The [Main()](/dotnet/csharp/programming-guide/main-and-command-args/) method is the entry point for C# applications.
146147

147-
Available code snippets vary for different programming languages. You can look at the available code snippets for your language by choosing **Edit** > **IntelliSense** > **Insert Snippet** or by selecting the **Ctrl**+**K**, **Ctrl**+**X** keys, and then choosing the folder for your programming language. For C#, the snippet list looks like this:
148+
Available code snippets vary by programming language. To view the available code snippets for your language, go to **Edit** > **IntelliSense** > **Insert Snippet** or select **Ctrl**+**K**, **Ctrl**+**X** keys, then select the folder for your programming language. For C#, the code snippet list looks like this:
148149

149150
:::image type="content" source="media/vs-2022/tutorial-code-snippet-list.png" alt-text="Screenshot of an IntelliSense pop-up for a C# code snippet list.":::
150151

@@ -194,7 +195,7 @@ The toolbar, which is the row of buttons under the menu bar in Visual Studio, ca
194195

195196
::: moniker range=">=vs-2022"
196197

197-
The Text Editor toolbar, which is the row of buttons under the menu bar in Visual Studio, helps make you more productive as you code. For example, you can toggle [IntelliSense](../ide/using-intellisense.md) completion mode, increase or decrease a line indent, or comment out code that you don't want to compile.
198+
The Text Editor toolbar, the row of buttons under the menu bar in Visual Studio, helps make you more productive as you code. For example, you can toggle [IntelliSense](../ide/using-intellisense.md) completion mode, increase or decrease a line indent, or comment out code you don't want to compile.
198199

199200
:::image type="content" source="media/vs-2022/tutorial-editor-toolbar.png" alt-text="Screenshot of the Text Editor toolbar in Visual Studio 2022.":::
200201

@@ -225,13 +226,13 @@ Let's comment out some code.
225226
select word;
226227
```
227228

228-
1. We're not using the `moreWords` variable, but we might use it later so we don't want to delete it. Instead, we'll comment out those lines. Select the entire definition of `moreWords` down to the closing semicolon, and then choose the **Comment out the selected lines** button on the Text Editor toolbar. If you prefer to use the keyboard, select **Ctrl**+**K**, **Ctrl**+**C**.
229+
1. The `moreWords` variable isn't currently being used, but you might use it later, so instead of deleting it, you can comment out those lines. Select the entire definition of `moreWords` down to the closing semicolon, and then select the **Comment out the selected lines** button on the Text Editor toolbar, or select **Ctrl**+**K**, **Ctrl**+**C**.
229230

230231
:::image type="content" source="media/vs-2022/tutorial-comment-out.png" alt-text="Screenshot of the Comment out button in the Text Editor toolbar in Visual Studio 2022.":::
231232

232233
The C# comment characters `//` are added to the beginning of each selected line to comment out the code.
233234
234-
When you want to uncomment lines, you can select them, and then choose the **Uncomment the selected lines** button on the Text Editor toolbar. If you prefer to use the keyboard, select **Ctrl**+**K**, **Ctrl**+**U**.
235+
To uncomment lines, you can select them, and then select **Uncomment the selected lines** button on the Text Editor toolbar, or select **Ctrl**+**K**, **Ctrl**+**U**.
235236

236237
:::image type="content" source="media/vs-2022/tutorial-uncomment.png" alt-text="Screenshot of the Uncomment button in the Text Editor toolbar in Visual Studio 2022.":::
237238

@@ -251,11 +252,11 @@ The code block collapses to just the first line, followed by an ellipsis (`...`)
251252

252253
::: moniker range=">=vs-2022"
253254

254-
We don't want to see the empty [constructor](/dotnet/csharp/programming-guide/classes-and-structs/constructors) that was generated for `Class1`, so to unclutter our view of the code, let's collapse it. Choose the small gray box with the minus sign inside it in the margin of the first line of the constructor. Or, if you prefer to use the keyboard, place the cursor anywhere in the constructor code and select the **Ctrl**+**M**, **Ctrl**+**M** keys.
255+
If you don't want to see the empty [constructor](/dotnet/csharp/programming-guide/classes-and-structs/constructors) that was generated for `Class1`, you can collapse it to unclutter your view of the code. Select the caret sign in the margin of the first line of the constructor. Or, if you prefer to use the keyboard, place the cursor anywhere in the constructor code and select the **Ctrl**+**M**, **Ctrl**+**M** keys.
255256

256-
:::image type="content" source="media/vs-2022/tutorial-collapse.png" alt-text="Screenshot of the Outlining collapse button in the Text Editor toolbar in Visual Studio 2022.":::
257+
:::image type="content" source="media/vs-2022/tutorial-collapse-down-arrow.png" alt-text="Screenshot of the Outlining collapse button in the Text Editor toolbar.":::
257258

258-
The code block collapses to just the first line, followed by an ellipsis (`...`). To expand the code block again, select the same gray box that now has a plus sign in it, or select **Ctrl**+**M**, **Ctrl**+**M** again. This feature is called [Outlining](../ide/outlining.md) and is especially useful when you're collapsing long methods or entire classes.
259+
The code block collapses to just the first line, followed by an ellipsis (`...`). To expand the code block again, select the caret sign (`>`), or select **Ctrl**+**M**, **Ctrl**+**M** again. This feature is called [Outlining](../ide/outlining.md) and is especially useful when you're collapsing long methods or entire classes.
259260

260261
::: moniker-end
261262

@@ -285,7 +286,7 @@ Let's peek at the definition of the `string` type.
285286

286287
A pop-up window appears with the definition of the `String` class. You can scroll within the pop-up window, or even peek at the definition of another type from the peeked code.
287288

288-
:::image type="content" source="media/vs-2022/tutorial-peek-definition.png" alt-text="Screenshot of the Peek definition window in Visual Studio 2022.":::
289+
:::image type="content" source="media/vs-2022/tutorial-symbol-peek-definition.png" alt-text="Screenshot of the Peek definition window in Visual Studio.":::
289290

290291
1. Close the peek definition window by choosing the small box with an "x" at the top right of the pop-up window.
291292

@@ -303,7 +304,7 @@ Let's peek at the definition of the `string` type.
303304
foreach (string str in qu
304305
```
305306

306-
You'll see IntelliSense show you **Quick Info** about the `query` symbol.
307+
You see IntelliSense show you **Quick Info** about the `query` symbol.
307308

308309
![Screenshot of an IntelliSense word completion pop-up in Visual Studio.](media/tutorial-intellisense-completion-list.png)
309310

@@ -336,6 +337,8 @@ Let's add a line of code to print out the ordered strings to the console window,
336337

337338
:::image type="content" source="media/vs-2022/tutorial-intellisense-completion-list.png" alt-text="Screenshot of an IntelliSense word completion pop-up in Visual Studio 2022.":::
338339

340+
If you're signed in with a GitHub account that has a Copilot subscription, you'll also see code suggestions appear in gray text.
341+
339342
1. To insert the rest of the word `query` by using IntelliSense word completion, select the **Tab** key.
340343

341344
1. Finish off the code block to look like the following code. You can practice further with code snippets by entering `cw` and then selecting **Tab** twice to generate the `Console.WriteLine` statement.

0 commit comments

Comments
 (0)