visual studio code(vscode): clang format plugin configuration - Hyeonykim/toolConfiguration GitHub Wiki

1. Install clang-format

2. Install clang-format plugin from visual studio code

  • Install clang-format plugin from visual studio code

    image

3. Config vscode formatter and clang-format

  • Open Setting Json

    image

    image

  • Append the following configuration

    {
        "editor.formatOnSave": true,
        "editor.formatOnSaveMode": "modifications",
        "[java]": {
            "editor.defaultFormatter": "mjohns.clang-format"
        },
        "clang-format.language.java.enable": true,
        "clang-format.language.java.style": "file",
        "clang-format.language.java.fallbackStyle": "none",
        "clang-format.executable.linux": "/usr/bin/clang-format",
        "clang-format.executable.windows": "C:\\Users\\username\\AppData\\Roaming\\npm\\clang-format",
    }
    

4. Save one of the following style to your project directory as ".clang-format"

5. For Your Information

  • Visual Studio Code Version

    image

    Version 1.67.2 (user setup)
    Commit c3511e6c69bb39013c4a4b7b9566ec1ca73fc4d5
    Date 2022-05-17T18:15:52.058Z
    Electron 17.4.1
    Chromium 98.0.4758.141
    Node.js 16.13.0
    V8 9.8.177.13-electron.0
    OS Windows_NT x64 10.0.22000