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/writing-and-refactoring-code-cpp.md
+30-24Lines changed: 30 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,9 @@
1
1
---
2
2
title: "Writing and refactoring code (C++) | Microsoft Docs"
3
3
ms.custom: ""
4
-
ms.date: "11/27/2017"
4
+
ms.date: "04/30/2018"
5
+
ms.reviewer: ""
6
+
ms.suite: ""
5
7
ms.technology: ["cpp-ide"]
6
8
ms.topic: "conceptual"
7
9
dev_langs: ["C++"]
@@ -12,42 +14,46 @@ ms.workload: ["cplusplus"]
12
14
---
13
15
# Writing and refactoring code (C++)
14
16
15
-
The Visual C++ code editor and IDE provide many coding aids. Some are unique to C++, and some are essentially the same for all Visual Studio languages. For more information about the shared features, see [Writing Code in the Code and Text Editor](/visualstudio/ide/writing-code-in-the-code-and-text-editor). Options for enabling and configuring C++-specific features are located in the [Text Editor C++ Advanced](/visualstudio/ide/reference/options-text-editor-c-cpp-advanced) dialog (**Tools | Options | Text Editor | C/C++| Advanced** or type "C++ Advanced" in **Quick Launch**). After choosing which option you want to set, you can get more help by pressing **F1** when the dialog is in focus. For general code formatting options, type `Editor C++` into **QuickLaunch**.
17
+
The Visual C++ code editor and IDE provide many coding aids. Some are unique to C++, and some are essentially the same for all Visual Studio languages. For more information about the shared features, see [Writing Code in the Code and Text Editor](/visualstudio/ide/writing-code-in-the-code-and-text-editor). Options for enabling and configuring C++-specific features are located under **Tools | Options | Text Editor | C/C++**. After choosing which option you want to set, you can get more help by pressing **F1** when the dialog is in focus. For general code formatting options, type `Editor C++` into **QuickLaunch**.
16
18
17
19
Experimental features, which may or may not be included in a future version of Visual Studio, are found in the [Text Editor C++ Experimental](/visualstudio/ide/reference/options-text-editor-c-cpp-experimental) dialog. In Visual Studio 2017 you can enable **Predictive Intellisense** in this dialog.
18
20
19
-
## Adding new code
21
+
## Adding new files
20
22
21
-
After creating a project, you can start coding in the files that were generated for you. To add new files, right-click on the project node in Solution Explorer and choose **Add | New**.
23
+
To add new files to a project, right-click on the project node in Solution Explorer and choose **Add | New**.
22
24
23
-
To set formatting options such as indents, brace completion, and colorization, type `C++ Formatting` into the **QuickLaunch** window.
25
+
## Formatting options
24
26
25
-
### IntelliSense
27
+
To set formatting options such as indents, brace completion, and colorization, type "C++ Formatting" into the **QuickLaunch** window. Visual Studio 2017 version 15.7 and later supports ClangFormat. You can configure it in the [C/C++ Formatting Property Page](/visualstudio/ide/reference/options-text-editor-c-cpp-formatting) under **Tools | Options | Text Editor | C/C++ | Formatting**.
IntelliSense is the name for a set of features that provide inline information about members, types, and function overloads. The following illustration shows the member list drop-down that appears as you type. You can press the tab key to enter the selected item text into your code file.
28
34
29
35

30
36
31
37
For complete information see [Visual C++ Intellisense](/visualstudio/ide/visual-cpp-intellisense).
32
38
33
-
###Insert Snippets
39
+
## Insert Snippets
34
40
35
41
A snippet is a predefined piece of source code. Right-click on a single point or on selected text to either insert a snippet or surround the selected text with the snippet. The following illustration shows the three steps to surround a selected statement with a for loop. The yellow highlights in the final image are editable fields that you access with the tab key. For more information, see [Code Snippets](/visualstudio/ide/code-snippets).
Add a new class from the **Project** menu by using the Class Wizard.
42
48
43
49

44
50
45
-
### Class Wizard
46
-
47
-
Modify or examine an existing class, or add a new class, using the Class Wizard. For more information, see [Adding Functionality with Code Wizards (C++)](../ide/adding-functionality-with-code-wizards-cpp.md).
51
+
You can also use Class Wizard to modify or examine an existing class.
48
52
49
53

50
54
55
+
For more information, see [Adding Functionality with Code Wizards (C++)](../ide/adding-functionality-with-code-wizards-cpp.md).
56
+
51
57
## Refactoring
52
58
53
59
Refactorings are available under the Quick Action context menu, or by clicking on a [light bulb](/visualstudio/ide/perform-quick-actions-with-light-bulbs) in the editor. Some are also found in the **Edit > Refactor** menu. These features include:
@@ -64,61 +70,61 @@ Refactorings are available under the Quick Action context menu, or by clicking o
64
70
65
71
Visual C++ shares many code navigation features with other languages. For more information, see [Navigating Code](/visualstudio/ide/navigating-code) and [Viewing the Structure of Code](/visualstudio/ide/viewing-the-structure-of-code).
66
72
67
-
###QuickInfo
73
+
## QuickInfo
68
74
69
75
Hover over a variable to see its type information.
Right click on the header name in an `#include` directive and open the header file.
76
82
77
83

78
84
79
-
###Peek Definition
85
+
## Peek Definition
80
86
81
87
Hover over a variable or function declaration, right-click, then choose **Peek Definition** to see an inline view of its definition. For more information, see [Peek Definition (Alt+F12)](/visualstudio/ide/how-to-view-and-edit-code-by-using-peek-definition-alt-plus-f12).
Hover over a variable or function declaration, right-click, then choose **Go To Definition** to open the document where the object is defined.
88
94
89
-
###View Call Hierarchy
95
+
## View Call Hierarchy
90
96
91
97
Right click on any function call and view a resursive list of all the functions that it calls, and all the functions that call it. Each function in the list can be expanded in the same way. For more information, see [Call Hierarchy](/visualstudio/ide/reference/call-hierarchy).
Right-click and choose **Toggle Header / Code File** to switch back and forth between a header file and its associated code file.
98
104
99
-
###Outlining
105
+
## Outlining
100
106
101
107
Right-click anywhere in a source code file and choose **Outlining** to collapse or expand definitions and/or custom regions to make it easier to browse only the parts you are interested in. For more information, see [Outlining](/visualstudio/ide/outlining).
Scrollbar map mode enables you to quickly scroll and browse through a code file without actually leaving your current location. Or click anywhere on the code map to go directly to that location.
113
+
Scrollbar map mode enables you to quickly scroll and browse through a code file without actually leaving your current location. Or click anywhere on the code map to go directly to that location. For more information, see [How to: Track your code by customizing the scrollbar](/visualstudio/ide/how-to-track-your-code-by-customizing-the-scrollbar).
108
114
109
115

110
116
111
-
###Generate graph of include files
117
+
## Generate graph of include files
112
118
113
119
Right click on a code file in your project and choose **Generate graph of include files** to see a graph of which files are included by other files.
114
120
115
121

116
122
117
-
###F1 Help
123
+
## F1 Help
118
124
119
-
Place the cursor on or just after any type, keyword or function and press F1 to go directly to the relevant MSDN reference topic. F1 also works on items in the error list, and in many dialog boxes.
125
+
Place the cursor on or just after any type, keyword or function and press F1 to go directly to the relevant reference topic on docs.microsoft.com. F1 also works on items in the error list, and in many dialog boxes.
120
126
121
-
###Quick Launch
127
+
## Quick Launch
122
128
123
129
To easily navigate to any window or tool in Visual Studio, simply type its name in the Quick Launch window in the upper right corner of the UI. The auto-completion list will filter as you type.
0 commit comments