title | description | ms.date | ms.topic | f1_keywords | dev_langs | helpviewer_keywords | author | ms.author | manager | |||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Options, Text Editor, C/C++, Formatting |
Learn how to use the Formatting options page and its subpages to set options for formatting code in the code editor when you are programming in C and C++. |
10/08/2021 |
reference |
|
|
|
tylermsft |
twhitney |
markl |
Use these property pages to change the default behavior of the code editor when you are programming in C or C++.
To access this page, in the Options dialog box, in the left pane, expand Text Editor, expand C/C++, and then click Formatting.
Note
Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Personalize the Visual Studio IDE.
This page has options for formatting statements and blocks as you type them.
The page also has options for configuring support for ClangFormat version 5.0. ClangFormat is a utility that makes it easy to style and format your code based on a set of rules that can be configured in a .clang-format or _clang-format file.
ClangFormat support is enabled by default. You can choose which of these common formatting conventions to apply to all your projects: LLVM, Google, Chromium, Mozilla, or WebKit. You can also create a custom format definition .clang-format or _clang-format file. If such a file is present in a project folder, Visual Studio uses it to format all source code files in that folder and its subfolders.
By default, Visual Studio runs clang-format.exe in the background and applies formatting as you type. You can also specify to run it only for manually invoked formatting commands Format Document (Ctrl+K, Ctrl+D) or Format Selection (Ctrl + K, Ctrl + F).
These pages enable various formatting customizations but are ignored if ClangFormat is enabled.