Skip to content

Latest commit

 

History

History
48 lines (34 loc) · 2.62 KB

options-text-editor-c-cpp-formatting.md

File metadata and controls

48 lines (34 loc) · 2.62 KB
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
VS.ToolsOptionsPages.Text_Editor.C/C++.Formatting.General
VS.ToolsOptionsPages.Text_Editor.C%2fC%2b%2b.Formatting.General
CPP
Text Editor Options dialog box, formatting
ClangFormat
tylermsft
twhitney
markl

Options, Text Editor, C/C++, Formatting

Use these property pages to change the default behavior of the code editor when you are programming in C or C++.

C++ Formatting property pages

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.

General Page

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.

Configuring ClangFormat options

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).

Indentation, New Lines, Spacing, Wrapping pages

These pages enable various formatting customizations but are ignored if ClangFormat is enabled.

See also