You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/ide/quickstart-editor.md
+26-24Lines changed: 26 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -14,45 +14,47 @@ ms.workload:
14
14
---
15
15
# Quickstart: Use the code editor
16
16
17
-
In this 10-minute introduction to the editor, 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 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.
18
18
19
19
If you haven't already installed Visual Studio, go to the [Visual Studio downloads](https://visualstudio.microsoft.com/downloads/?utm_medium=microsoft&utm_source=docs.microsoft.com&utm_campaign=button+cta&utm_content=download+vs2017) page to install it for free.
20
20
21
-
This quickstart assumes you are already familiar with a programming language. If you aren't, we suggest you look at one of the programming quickstarts first, such as create a web app with [Python](../ide/quickstart-python.md) or [C#](../ide/tutorial-csharp-aspnet-core.md), or create a console app with [Visual Basic](../ide/quickstart-visual-basic-console.md) or [C++](../ide/getting-started-with-cpp-in-visual-studio.md).
21
+
This quickstart assumes you're already familiar with a programming language. If you aren't, we suggest you look at one of the programming quickstarts first, such as create a web app with [Python](../ide/quickstart-python.md) or [C#](../ide/tutorial-csharp-aspnet-core.md), or create a console app with [Visual Basic](../ide/quickstart-visual-basic-console.md) or [C++](../ide/getting-started-with-cpp-in-visual-studio.md).
22
22
23
23
## Create a new code file
24
24
25
-
Start by creating a new file and adding some code to it. Notice that we do not have to create a project to gain some of the benefits that the editor offers.
25
+
Start by creating a new file and adding some code to it.
26
26
27
27
1. Open Visual Studio, and from the **File** menu on the menu bar, choose **New** > **File**.
28
28
29
29
1. In the **New File** dialog box, under the **General** category, choose **Visual C# Class**, and then choose **Open**.
30
30
31
-
A new file opens in the editor with the skeleton of a C# class.
31
+
A new file opens in the editor with the skeleton of a C# class. (Notice that we don't have to create a full Visual Studio project to gain some of the benefits that the code editor offers; all you need is a code file!)
32
+
33
+

32
34
33
35
## Use code snippets
34
36
35
-
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++. Let's add the C# `void Main` snippet to our file.
37
+
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++. Let's add the C# `void Main` snippet to our file.
36
38
37
-
1. Place your cursor below the closing brace of the `Class1` constructor and enter the characters `svm`.
39
+
1. Place your cursor just above the final closing brace **}** in the file, and type the characters `svm` (which stands for `static void Main`—don't worry too much if you don't know what that means).
38
40
39
-
You see an **IntelliSense**dialog box appear with information about the `svm` snippet.
41
+
A pop-up dialog box appears with information about the `svm` code snippet.

42
44
43
45
1. Press **Tab** twice to insert the code snippet.
44
46
45
-
You see the `static void Main()` method signature get added to the file. The `Main()` method is the entry point for C# applications.
47
+
You 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.
46
48
47
-
The available code snippets vary for different languages. You can look at the available code snippets for your programming language by choosing **Edit** > **IntelliSense** > **Insert Snippet**, and then choosing your language's folder. For C#, the list looks like this:
49
+
The 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**, and then choosing your language's folder. For C#, the list looks like this:
The list includes snippets for creating a class, a constructor, `Console.WriteLine()`, `for` loops, `if` and `switch` statements, and more.
53
+
The list includes snippets for creating a [class](/dotnet/csharp/programming-guide/classes-and-structs/classes), a [constructor](/dotnet/csharp/programming-guide/classes-and-structs/constructors), a [for](/dotnet/csharp/language-reference/keywords/for) loop, an [if](/dotnet/csharp/language-reference/keywords/if-else) or [switch](/dotnet/csharp/language-reference/keywords/switch) statement, and more.
52
54
53
55
## Comment out code
54
56
55
-
The toolbar provides a number of buttons to make you more productive as you code. For example, you can toggle IntelliSense completion mode, increase or decrease an indent, set a bookmark, or comment out code. In this section, we'll comment out some code that we don't want to compile.
57
+
The toolbar, which is the row of buttons under the menu bar in Visual Studio, can help make you more productive as you code. For example, you can toggle IntelliSense completion mode ([IntelliSense](using-intellisense.md) is a coding aid that displays a list of matching methods, amongst other things), increase or decrease a line indent, or comment out code that you don't want to compile. In this section, we'll comment out some code.
1. We're not using the `morewords` variable, but we may use it later so we don'twanttocompletelydeleteit. Instead, let's comment out those lines. Select the entire definition of `morewords` to the closing semi-colon, and then choose the **Comment out the selected lines** button on the toolbar. If you prefer to use the keyboard, press **Ctrl**+**K**, **Ctrl**+**C**.
Wedon't want to see the empty [constructor](/dotnet/csharp/programming-guide/classes-and-structs/constructors) for `Class1` that was generated, so to unclutter our view of the code, let'scollapseit. Choosethesmallgrayboxwiththeminussigninsideitinthemarginofthefirstlineoftheconstructor. Or, ifyou're a keyboard user, place the cursor anywhere in the constructor code and press **Ctrl**+**M**, **Ctrl**+**M**.
TheVisualStudioeditormakesiteasytoinspectthedefinitionofatype, method, etc. Onewayistonavigatetothefilethatcontainsthedefinition, for example by choosing **Go to Definition** anywhere the symbol is referenced. An even quicker way that doesn't move your focus away from the file you're working in is to use [Peek Definition](../ide/go-to-and-peek-definition.md#peek-definition). Let's peek at the definition of the `string` type.
Apop-upwindowappearswiththedefinitionofthe `String` class. You can scroll within the pop-up window, or even peek at the definition of another type from the peeked code.
104
106
@@ -108,7 +110,7 @@ The Visual Studio editor makes it easy to inspect the definition of a type, meth
108
110
109
111
## Use IntelliSense to complete words
110
112
111
-
[IntelliSense](../ide/using-intellisense.md) is an invaluable resource when you're coding. It can show you information about available members of a type, or parameter details for different overloads of a method. You can also use IntelliSense to complete a word after you type enough characters to disambiguate it. Let's add a line of code to print out the ordered strings to the console window.
113
+
[IntelliSense](../ide/using-intellisense.md) is an invaluable resource when you're coding. It can show you information about available members of a type, or parameter details for different overloads of a method. You can also use IntelliSense to complete a word after you type enough characters to disambiguate it. Let's add a line of code to print out the ordered strings to the console window, which is the standard place for output from the program to go.
112
114
113
115
1. Below the `query` variable, start typing the following code:
114
116
@@ -118,9 +120,9 @@ The Visual Studio editor makes it easy to inspect the definition of a type, meth
118
120
119
121
You see IntelliSense show you **Quick Info** about the `query` symbol.
120
122
121
-

123
+

122
124
123
-
1. To insert the rest of the word `query` by using IntelliSense's "Complete Word" functionality, press **Tab**.
125
+
1. To insert the rest of the word `query` by using IntelliSense's word completion functionality, press **Tab**.
124
126
125
127
1. Finish off the code block to look like the following code. You can even practice using code snippets again by entering `cw` and then pressing **Tab** twice to generate the `Console.WriteLine` code.
126
128
@@ -133,13 +135,13 @@ The Visual Studio editor makes it easy to inspect the definition of a type, meth
133
135
134
136
## Refactor a name
135
137
136
-
Nobody gets code right the first time, and one of the things you might want to change is the name of a variable or method. Let's try out Visual Studio's [refactor](../ide/refactoring-in-visual-studio.md) functionality to rename the `_words` variable to `words`.
138
+
Nobody gets code right the first time, and one of the things you might have to change is the name of a variable or method. Let's try out Visual Studio's [refactor](../ide/refactoring-in-visual-studio.md) functionality to rename the `_words` variable to `words`.
137
139
138
-
1. Place your cursor over the definition of the `words` variable, and choose **Rename** from the right-click or context menu, or press **Ctrl**+**R**, **Ctrl**+**R**.
140
+
1. Place your cursor over the definition of the `_words` variable, and choose **Rename** from the right-click or context menu, or press **Ctrl**+**R**, **Ctrl**+**R**.
139
141
140
142
A pop-up **Rename** dialog box appears at the top right of the editor.
141
143
142
-
1. Enter the desired name `words`. Notice that the reference to `words` in the query is also automatically renamed. Before you press **Enter**, select the **Include comments** checkbox in the **Rename** pop-up box.
144
+
1. Enter the desired name **words**. Notice that the reference to `words` in the query is also automatically renamed. Before you press **Enter**, select the **Include comments** checkbox in the **Rename** pop-up box.
143
145
144
146

145
147
@@ -149,12 +151,12 @@ Nobody gets code right the first time, and one of the things you might want to c
149
151
150
152
## Next steps
151
153
152
-
You've completed this Quickstart for the Visual Studio editor! Next you might try out some of the other Quickstarts for the Visual Studio IDE, look at more ways to [Navigate code](../ide/navigating-code.md), or check out the links to more information about the features we looked at. Otherwise, happy coding!
154
+
You've completed this Quickstart for the Visual Studio editor. Next, you might try out some of the other Quickstarts for the Visual Studio development environment such as [Quickstart: Projects and solutions](../ide/quickstart-projects-solutions.md) or [Quickstart: Personalize Visual Studio](../ide/quickstart-personalize-the-ide.md), look at more ways to [Navigate code](../ide/navigating-code.md), or check out the links to more information about the features we looked at. Otherwise, happy coding!
153
155
154
156
## See also
155
157
156
158
-[Quickstart: First look at the Visual Studio IDE](../ide/quickstart-ide-orientation.md)
157
-
-[Quickstart: Personalize the Visual Studio IDE and editor](../ide/quickstart-personalize-the-ide.md)
0 commit comments