|
1 | 1 | --- |
2 | 2 | title: "Set your C++ coding preferences in Visual Studio" |
3 | | -ms.description: "Customize C++ formatting, colors, layout, line numbers, menus and more in the Visual Studio IDE." |
| 3 | +ms.description: "Customize C++ formatting, colors, layout, line numbers, and menus in the Visual Studio IDE." |
4 | 4 | ms.topic: "overview" |
5 | 5 | ms.date: "09/27/2019" |
6 | 6 | --- |
7 | 7 |
|
8 | 8 | # Set your C++ coding preferences in Visual Studio |
9 | 9 |
|
10 | | -You can make your C++ coding experience more convenient, productive and pleasurable by personalizing Visual Studio. You can customize the menus and toolbars, arrange the window layout, set color themes, specify C++ formatting rules, including several flavors of ClangFormat, and create custom keyboard shortcuts. You can synchronize your preferences across multiple machines, and create and store multiple sets of preferences and share them with teammates. You can install extensions from the Visual Studio Marketplace which provide additional custom behavior. Many of these options are documented under [Personalize the Visual Studio IDE](/visualstudio/ide/personalizing-the-visual-studio-ide). |
| 10 | +You can make your C++ coding experience more convenient, productive, and pleasurable by personalizing Visual Studio. You can: |
| 11 | + |
| 12 | +- Customize the menus and toolbars. |
| 13 | +- Arrange the window layout. |
| 14 | +- Set color themes. |
| 15 | +- Specify C++ formatting rules, including several styles of ClangFormat. |
| 16 | +- Create custom keyboard shortcuts. |
| 17 | + |
| 18 | +You can synchronize your preferences across multiple machines, and create and store multiple sets of preferences and share them with teammates. You can install extensions from the Visual Studio Marketplace, giving you additional options for customizing behavior. For more information, see [Personalize the Visual Studio IDE](/visualstudio/ide/personalizing-the-visual-studio-ide). |
11 | 19 |
|
12 | 20 | ## Arrange window layout |
13 | 21 |
|
14 | | -Within the Visual Studio window, the space is divided into the main menu, the toolbar, the code editor (or document window), and tool windows (**Solution Explorer**, **Error List**, and so on). Some windows overlap each other in the same position. For example, **Solution Explorer**, **Class View**, **Resource View**, and **Source Control Explorer** all share the same default position. You switch between them by clicking on the tabs at the bottom of the frame. To make two or more of these windows visible at the same time, just drag one of them by its title bar to a new position. You can dock it against one of the Visual Studio main window borders, or you can float it. The following illustration shows the **Team Explorer** window in the process of being dragged from its default position to a new docked position on the left side of the code editor. The blue shaded area shows where the window will be placed when the mouse button is released. |
| 22 | +Within the Visual Studio window, the space is divided into the main menu, the toolbar, the code editor (or document window), and tool windows (such as Solution Explorer and Error List). Some windows overlap each other in the same position. For example, Solution Explorer, Class View, Resource View, and Source Control Explorer all share the same default position. You switch among them by selecting the tabs at the bottom of the frame. To make two or more of these windows visible at the same time, just drag one of them by its title bar to a new position. You can dock it against one of the Visual Studio main window borders, or you can float it. |
| 23 | + |
| 24 | +The following screenshot shows the **Team Explorer** window being dragged from its default position to a new, docked position on the left side of the code editor. The blue shaded area shows where the window will be placed when the mouse button is released. |
15 | 25 |
|
16 | | - |
| 26 | + |
17 | 27 |
|
18 | | -In the document window, each open file is contained in a tabbed frame. You can float or lock these tabs just like tool windows. For more information, see [Customize window layouts in Visual Studio](/visualstudio/ide/customizing-window-layouts-in-visual-studio). |
| 28 | +In the document window, each open file is contained in a tabbed frame. You can float or lock these tabs, just like tool windows. For more information, see [Customize window layouts in Visual Studio](/visualstudio/ide/customizing-window-layouts-in-visual-studio). |
19 | 29 |
|
20 | 30 | To hide all the tool windows and maximize the Code Editor window, press **Alt** + **Shift** + **Enter** to toggle *full-screen mode*. |
21 | 31 |
|
22 | 32 | ## Set C++ coding styles and formatting |
23 | 33 |
|
24 | | -You can specify many individual code formatting options such as indentation and brace positions by navigating to **Tools** > **Options** > **Text Editor** > **C/C++** > **Formatting** (or type **Ctrl + Q** and search for "Formatting"). Alternatively, you can specify one of the [ClangFormat](https://clang.llvm.org/docs/ClangFormat.html) styles (or your own custom ClangFormat style): |
| 34 | +You can specify many individual code formatting options, such as indentation and brace positions. To do so, go to **Tools** > **Options** > **Text Editor** > **C/C++** > **Formatting** (or type **Ctrl + Q** and search for "Formatting"). Alternatively, you can specify one of the [ClangFormat](https://clang.llvm.org/docs/ClangFormat.html) styles (or your own custom ClangFormat style). |
25 | 35 |
|
26 | | - |
| 36 | + |
27 | 37 |
|
28 | 38 | For more information about all the formatting options, see [Options, Text Editor, C/C++, Formatting](/visualstudio/ide/reference/options-text-editor-c-cpp-formatting). |
29 | 39 |
|
30 | 40 | ## Set the color theme |
31 | 41 |
|
32 | | -To set a light or dark background, type **Ctrl + Q** and search for "Color Theme". You can also get there via **Tools** > **Options** > **Environment** and choose **Color Theme**: |
| 42 | +To set a light or dark background, type **Ctrl + Q** and search for "Color Theme". You can also find these by going to **Tools** > **Options** > **Environment**, and choosing **Color Theme**. |
33 | 43 |
|
34 | | - |
| 44 | + |
35 | 45 |
|
36 | | -The following image shows the dark theme: |
| 46 | +For example, here's the dark theme: |
37 | 47 |
|
38 | | - |
| 48 | + |
39 | 49 |
|
40 | 50 | ## Customize code colorization |
41 | 51 |
|
42 | | -In Visual Studio 2019 you can choose from three predefined *color schemes* which specify how code elements are colorized in the editor. To choose a theme, navigate to **Tools** > **Options** > **Text Editor** > **C/C++** > **View** and choose **Color Scheme**: |
| 52 | +In Visual Studio 2019, you can choose from three predefined *color schemes*. These specify how code elements are colorized in the editor. To choose a theme, go to **Tools** > **Options** > **Text Editor** > **C/C++** > **View**, and choose **Color Scheme**: |
43 | 53 |
|
44 | | - |
| 54 | + |
45 | 55 |
|
46 | | -In the **Visual Studio 2017** color scheme, most code elements are simply black. In the **Enhanced** color scheme, functions, local variables, macros, and other elements are colorized. In the **Enhanced (Globals vs. Members)** scheme, global functions and variables are colorized to contrast with class members. The default mode is **Enhanced** and it looks like this: |
| 56 | +In the color scheme called **Visual Studio 2017**, most code elements are simply black. In the **Enhanced** color scheme, functions, local variables, macros, and other elements are colorized. In the **Enhanced (Globals vs. Members)** scheme, global functions and variables are colorized to contrast with class members. The default mode is **Enhanced**, and it looks like this: |
47 | 57 |
|
48 | | - |
| 58 | + |
49 | 59 |
|
50 | | -Regardless of which theme or color scheme is active, you can customize the font and colors for individual code elements by navigating to **Tools** > **Options** > **Environment** > **Fonts and Colors** (or type **Ctrl + Q** and search for "Fonts"). Scroll down the list of display items until you see the C++ options: |
| 60 | +Regardless of which theme or color scheme is active, you can customize the font and colors for individual code elements. To do this, go to **Tools** > **Options** > **Environment** > **Fonts and Colors** (or type **Ctrl + Q** and search for "Fonts"). Scroll down the list of display items until you see the C++ options. |
51 | 61 |
|
52 | | - |
| 62 | + |
53 | 63 |
|
54 | | -Colors that you set here override the values defined for the color schemes. You have to set a color back to **Default** if you have changed it but want to use the default colors for the color scheme. |
| 64 | +Colors that you set here override the values defined for the color schemes. If you want to go back to the default colors for the color scheme, set a color back to **Default**. |
55 | 65 |
|
56 | 66 | ## Customize the toolbars |
57 | 67 |
|
58 | | -The toolbars provide a convenient way to issue commands with a single mouse-click, rather than using the menus or keyboard shortcuts. Visual Studio includes a standard set of toolbars. For standard C++ development, the most useful toolbars are probably Standard, Text Editor, Build, Debug, Source Control, and possibly Compare Files. For Windows development, the Dialog Editor and Image Editor are useful for laying out dialogs and editing icons. |
| 68 | +The toolbars provide a convenient way to issue commands with a single click, rather than by using the menus or keyboard shortcuts. Visual Studio includes a standard set of toolbars. For standard C++ development, the most useful toolbars are probably Standard, Text Editor, Build, Debug, Source Control, and Compare Files. For Windows development, the Dialog Editor and Image Editor are useful for laying out dialog boxes and editing icons. |
59 | 69 |
|
60 | 70 | Hover over the icons in the toolbar to see which command it represents: |
61 | 71 |
|
62 | | - |
| 72 | + |
63 | 73 |
|
64 | | -You can add or remove commands or create a custom toolbar by clicking the down-arrow. To move the toolbar to a new location, drag it by the dotted bar on the left: |
| 74 | +You can add or remove commands, or create a custom toolbar, by selecting the down-arrow. To move the toolbar to a new location, drag it by the dotted bar on the left. |
65 | 75 |
|
66 | | -. |
| 76 | +. |
67 | 77 |
|
68 | 78 | For more information, see [How to: Customize menus and toolbars in Visual Studio](/visualstudio/ide/how-to-customize-menus-and-toolbars-in-visual-studio). |
69 | 79 |
|
70 | 80 | ## Show or hide line numbers |
71 | 81 |
|
72 | | -To specify whether line numbers show on the left of the editor windows, navigate to and check or un-check **Line Numbers**: |
| 82 | +You can specify whether line numbers show on the left of the editor windows. In **Options**, under **C/C++**, select **General**. In the **Settings** section, select or clear **Line numbers**, depending on your preference. |
73 | 83 |
|
74 | | - |
| 84 | + |
75 | 85 |
|
76 | 86 | ## Create keyboard shortcuts |
77 | 87 |
|
78 | | -All commands in Visual Studio can be made with keyboard shortcuts using various combinations of keys with the Ctrl, Alt and Shift keys. You can create your own shortcuts by navigating to **Tools** > **Options** > **Environment** > **Keyboard** (or type **Ctrl + Q** and search for "shortcuts"). For more information, see [Identify and customize keyboard shortcuts in Visual Studio](/visualstudio/ide/identifying-and-customizing-keyboard-shortcuts-in-visual-studio). |
| 88 | +Many commands in Visual Studio have *keyboard shortcuts*, key combinations with the Ctrl, Alt, and Shift keys. You can modify these keyboard shortcuts or create new ones of your own in Visual Studio. Go to **Tools** > **Options** > **Environment** > **Keyboard** (or type **Ctrl + Q** and search for "shortcuts"). For more information, see [Identify and customize keyboard shortcuts in Visual Studio](/visualstudio/ide/identifying-and-customizing-keyboard-shortcuts-in-visual-studio). |
0 commit comments