Nothing Special   »   [go: up one dir, main page]

MAC VSCode uses clang-format format C ++ code

tags: A little white note in work  visual studio code

First, installation

Need to install the plug-in C / C ++, it is not recommended to use the CLANG-Format plugin. After all, C / C ++ has supported the Clang-Format formatting operation. There is also a benefit of installing this clang-format plugin, with Clang-Format. In order to simplify the VSCode setting interface, I will choose to install independently.

First update the installation software, (If you don't update the installation package, there is a pit, you can understand why it), execute Brew Upgrade, this process is a bit slow, you can learn how to skip the updated software, and finally execute Brew Install LLVM

Find Clang-Format Path: Find / usr -name clang-format, my path is: /usr/local/cellar/llvm/11.1.0_1/bin/clang-format

Second, configure vscode

New directory Demo, store two files: .clang-format, demo.cpp

The .CLANG-FORMAT is stored in the form of a custom code format rule in the form of the key: value: Value, the rule is described:http://clang.llvm.org/docs/ClangFormatStyleOptions.html

Vscode configuration file has three, user configuration, work space configuration, folder configuration (need to know yourself)

Settings.json in the user directory I configured, add the content in the settings.json file:

    "C_Cpp.clang_format_path": "/usr/local/Cellar/llvm/11.1.0_1/bin/clang-format",
    "C_Cpp.clang_format_fallbackStyle": "Visual Studio",
    "C_Cpp.clang_format_style": "file",

Save, edit the code within DEMO.CPP, right click on the formatted document, select C / C ++, then click, and format the document.

Intelligent Recommendation

clang-format format code

clang-format is a tool to automatically format C/C++/Objective-C code, so that developers don't need to worry about style issues during code reviews. installation Common commands are as...

macbook vscode configure clang-format and automatically format the code when saving

Search clang-format under the extensions tab of vscode, install (I have already installed it in the picture); Enter brew install clang-format in the terminal (Mac needs to be installed in advance, bre...

Mac installation Clang-Format

Giant's shoulder: GOLAND file formatting configuration Steps: 1, update HomeBrew resources 2, install Clang-Format 3, configure Goland Arguments fill in: 4, save the Goland configuration and restart G...

Sublime Text 3 under Windows 3 uses Clang Format to format C ++ code

ref:    The installation of Clang-Format under WINDOWS https://gist.github.com/danielTobon43/51764026f95240bbd03991089f0380a8 LLVM download: Download LLVM releases After installation Install...

[C ++] [Code Typesetting] Clang-Format Style Encyclopedia

Clang-Format is a universal code typesetting plugin that can be used in multiple languages ​​and multiple IDEs Clang-Format full style description can be viewed in the official documentation:ClangForm...

More Recommendation

VisualStudio sets C++ code clang encoding format

VisualStudio sets clang encoding format The default C++ format of VisualStudio is the default, alt + F8 automatic format code;   If the code is required to be in clang format, it can be set for s...

Ubuntu18.04 VSCode Configure Clang-Format

Series article catalog Article catalog Series article catalog Foreword First, Clang-Format Second, use steps 1, Visual Studio Code installation Clang-Format 2, install Clang-Format in the command line...

Code Specification and Formatting Tools (VSCode, Clang-Format, Git)

Article catalog instruction Linux kernel code style 1) indent 2) Disperse long rows and strings 3) Placement of braces and spaces 3.1) Space 4) Name 5) Typedef 6) function 7) Concentrated function exi...

Using CLANG-FORMAT to format C ++ code under Linux

1 Overview Clang-format is used to format the code, with the comes with the contained rules:LLVM、Google、Chromium、Mozilla、WebKit 2. Command Install command:sudo apt install clang-format Operation comma...

Vscode uses prettier to format code

The previous article mentioned some rules validation for canceling eslint. Similarly, we can modify the formatting configuration and add the appropriate rules. Proceed as follows First download the pr...

Copyright  DMCA © 2018-2025 - All Rights Reserved - www.programmersought.com  User Notice

Top