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

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

tags: sublime  clang  format  C++  

ref: 

 

The installation of Clang-Format under WINDOWS

https://gist.github.com/danielTobon43/51764026f95240bbd03991089f0380a8

LLVM download:

Download LLVM releases

After installation

Install the Clang Format plug -in in Sublime Text Package Control

Then set the plug -in:

Setting up clang-format

  • Go to Preferences->Package Control: Install Package
  • Install Clang Format
  • Go to Preferences->Package Settings->Clang Format->Setting-User, set as following:
{
    "binary": "C:/Program Files/LLVM/bin/clang-format.exe",
    "format_on_save": true,
    "style": "Custom",
}
  • Go to Preferences->Package Settings->Clang Format->Custom Style-User, add:
{
    "Language": "Cpp",
    "TabWidth": 4,
    "AlignTrailingComments": "true",
    "UseTab": "Never",
}

You can copy the default.

  • Save and restart sublime text
  • Go to any script page, save it and see the difference

Finally, set the shortcut key Key Bindings of the plug -in, use the shortcut key to format the code format

Code formatting and saving configuration file under Linux

APT-get install clong-format-7 (other system versions may be-get install clong-format)

clang-format-7 -i xxx.cpp -style=Google

Save the configuration file:

clang-format -style=Google -dump-config > .clang-format

Configuration file modification

tab size

SortIncludes: false

Load the configuration file for formatting (automatically find the .clang-Format configuration file from the current upper directory):

clang-format-7 -style=file -i xxx.cpp 

Intelligent Recommendation

Sublime Text 3 format plug mounted Json

There are many online json analytic site, but occupied a json parsing a tab of Chrome on the computer memory somewhat bargain (slightly more open plug-in), we still decided to use the Sublime to resol...

Qt Creator uses clang-format to format code

Creator does not provide formatting code by default, but we can use clan-format to format the code through some plugins. Install clang-format On a Unix/Linux system, use your package manager to instal...

Use of Sublime Text 3 + EsLinter under Windows

It’s really annoying to configure it, write an article for your reference. Starting URL: http://szhshp.org Last updated: 2018-03-09 ESLint A well-known plugin for JS code specification checking ...

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

QtCreator adapts clang-format under windows

Table of contents 1. Introduction 2. Content 3. Related Links 1. Introduction Version: clang-format-11.0.0 Operating system: win10_64 Time: 2019-09-16 Note: It is set to reprint only because there are...

More Recommendation

ubuntu16.04 uses ppa format to add source (take adding and u install Sublime Text 3 Installer as an example)

The specific adding command can be searched in the URL below  https://launchpad.net/ubuntu For example, when installing sublime, you can enter sublime in the search box above, and the following w...

VSCode uses Clang-Format formatting code

Use VSCode formatting code Use VSCode formatting code Steps Use VSCode formatting code You can automatically format the C/C ++ code on the VSCode to automatically format the C/C ++ code to configure t...

Install the Clang-Format Code Style under Ubuntu16.04

Reference link: 1. Open the source list first: Add: Add: deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial main deb-src http://apt.llvm.org/xenial/ llvm-toolchain-xenial main 2, run at the termina...

Custom sublime text 3 plugin --- php file format

Last time I wrote about the sublime text 3 custom plugin steps, can only be said to play a role in the introduction of jade, does not have much practical function, this time I will combine the needs o...

Sublime Text 3 HTML/CSS/JS prettify Format Vue files

1. Open the configuration file Preferences > Package settings > HTML/CSS/JS prettify > Plugins Options-Default 2. Find "global_file_rules" > "html" > "allowed_f...

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

Top