Skip to content
| Marketplace
Sign in
Visual Studio Code>Formatters>clang-hesongNew to Visual Studio Code? Get it now.
clang-hesong

clang-hesong

hesong-tools

|
10 installs
| (0) | Free
C/C++ identifier renaming: batch-convert symbols to snake_case, camelCase, or PascalCase via Clang AST. Also optional comment strip, brace forcing, blank-line cleanup. Windows x64.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

clang-hesong

C/C++ identifier renaming (snake_case / camelCase / PascalCase) and optional code cleanup — VS Code extension (Windows x64). Right-click a file → clang-hesong: Run On This File → rewrites the file on disk per .vscode/clang-hesong.json.

Publisher: HeSong Tools · Platform: Windows only · Not affiliated with LLVM / Microsoft C/C++.

Contents

1. Configuration 5. Troubleshooting
2. Key features (2.1 · 2.2 · 2.3 · 2.4) 6. Third-party licenses
3. Quick start (3.1 · 3.2) 7. Reporting issues
4. Commands (4.1) 8. Requirements

1. Configuration

Config JSON keys are the features. File: .vscode/clang-hesong.json (create via clang-hesong: Open Config). The extension sets input_output_file automatically — do not add input_dir / output_dir (CLI only).

Parameter Required Type Default What it does
naming_style Yes "snake" | "camel" | "pascal" — Main feature: unify eligible identifiers to one naming convention (§2.1)
this_module_include_dirs No* string[] omitted For external symbols (declared outside the file being formatted): rename at use sites only if the symbol’s declaration header path matches a listed directory — marks your module API (§2.2)
compile_args Yes string[] — Clang -std, -I, -D, … so the file can be parsed (§2.3)
clear_all_blank_lines_inside_function No boolean false Remove extra blank lines inside function bodies
cut_all_comments No boolean false Strip almost all comments after rewrite
cut_all_comments_exception_substr_set No string[] omitted When cutting comments: keep only comments containing a listed substring (requires cut_all_comments: true)
force_braces_for_single_statement_after_condition No boolean false Wrap single-statement if / for / while bodies in { }
blank_lines_between_fucntion_and_any_object No integer -1 (off) Blank lines between top-level declarations (fucntion spelling is intentional)

*Required for real multi-file projects when renaming module API at call sites.

Example (placeholders — replace paths):

{
  "naming_style": "snake",
  "this_module_include_dirs": [
    "C:\\fake-dir1\\src",
    "C:\\fake-dir2\\include"
  ],
  "compile_args": [
    "-std=c++20",
    "-IC:\\fake-dir1\\src",
    "-IC:\\fake-dir2\\include",
    "-IC:\\fake-dir3\\thirdparty\\include"
  ],
  "clear_all_blank_lines_inside_function": true,
  "cut_all_comments": true,
  "cut_all_comments_exception_substr_set": ["hesong", "Copyright"],
  "force_braces_for_single_statement_after_condition": true,
  "blank_lines_between_fucntion_and_any_object": 2
}

Sample file: clang-hesong.json.example


2. Key features (detailed)

2.1 naming_style

Main feature. Rewrites eligible C/C++ identifiers so they all follow one naming convention. Set in JSON, run on a file; change the value and run again to switch styles.

Value Style Example
"snake" snake_case camelCaseFunction → camel_case_function
"camel" camelCase snake_case_function → snakeCaseFunction
"pascal" PascalCase snake_case_function → SnakeCaseFunction

Same identifiers, three styles:

Original "snake" "camel" "pascal"
camelCaseFunction camel_case_function camelCaseFunction CamelCaseFunction
PascalCaseType pascal_case_type pascalCaseType PascalCaseType
snake_case_var snake_case_var snakeCaseVar SnakeCaseVar
HTTPResponse http_response httpResponse HttpResponse

Example ("naming_style": "snake"):

// before
class MyWidget {
    void doSomething();
    int itemCount;
};

// after (eligible names in this file)
class my_widget {
    void do_something();
    int item_count;
};

Applies to: functions, methods, variables, parameters, class/struct/enum members, C++17 structured-binding names, types, typedef / using aliases, enum constants, identifiers inside #define bodies (when eligible). Does not change #includes, formatting, logic, or the program entry symbol main. Qualified type names after :: (e.g. nlohmann::json) are left unchanged.

Which symbols are renamed:

Situation Renamed?
Declared in the file you run on Yes
External symbol; declaration header matches this_module_include_dirs Yes at use sites in this file
External symbol; declaration outside this_module_include_dirs No (STL, third-party, …)
this_module_include_dirs empty / omitted Only in-file declarations
Virtual override of external base No

2.2 this_module_include_dirs

This does not mean “only rename symbols under these directories.”
It answers a different question: for a symbol used in the file you are formatting but declared in another file (an external symbol) — should that name be rewritten here to follow naming_style?

Rule: look at where the symbol is declared (its declaration header’s file path). If that path matches one of the directories in this_module_include_dirs, the symbol is treated as your module’s API and is renamed at use sites in the file being formatted (function calls, types, members, …). If the declaration comes from outside that set (third-party SDK, STL, other libs), the name is left unchanged.

Therefore: functions from other modules and the C/C++ standard library (e.g. std::vector, printf) are not wrongly renamed — their declaration headers are not under this_module_include_dirs, so calls to them in your file keep the original spelling.

Purpose: directory roots for your module’s headers. Used with naming_style to decide which external declarations count as module API.

Rule (matches should_rename_decl + apply_naming_style_to_ref in the bundled exe):

Situation Renamed in the file you run on?
Symbol declared in the main file (isWrittenInMainFile) Yes — definition and uses in this file
External symbol; declaration is in a header whose path matches this_module_include_dirs Yes — uses in this file (calls, types, members). No automatic rewrite of that .h on disk
External symbol; declaration file path does not match those directories No — third-party / STL / other libs keep original spelling
this_module_include_dirs empty / omitted Only symbols declared in the main file
Virtual method overrides a base outside your module No

How “matches” works: is_this_module_header checks whether the declaration header’s absolute file path contains one of the configured directory strings (case-insensitive substring). List the roots where your API headers live — not third-party -I trees.

Do not list third-party or system header roots here. Put those paths only in compile_args -I so Clang can parse them. Listing them in this_module_include_dirs would mark foreign APIs as “yours” and break builds.

compile_args -I vs this_module_include_dirs — do not confuse them:

Config key Role What to list
compile_args -I Clang must parse every #include Your code + all third-party header paths (and -D, -std, …)
this_module_include_dirs Which external declarations count as module API for naming_style Only directories that contain headers you own

Example (placeholders):

"this_module_include_dirs": [
  "C:\\fake-dir1\\src",
  "C:\\fake-dir2\\include"
],
"compile_args": [
  "-std=c++20",
  "-IC:\\fake-dir1\\src",
  "-IC:\\fake-dir2\\include",
  "-IC:\\fake-dir3\\thirdparty\\include"
]
  • fake-dir1 / fake-dir2 — your module header roots. A function declared in fake-dir2\\api\\foo.h and called from the .cpp you are formatting will be renamed with naming_style at the call site in that .cpp.
  • fake-dir3\\thirdparty — in compile_args only (Clang needs the -I to parse #includes); not in this_module_include_dirs, so third-party names like SomeSdkFunction stay unchanged.

Rule of thumb: Every path in this_module_include_dirs should usually also have a matching -I in compile_args. The reverse is not true — many -I paths are third-party and belong only in compile_args.

Single-file mode (extension): only the file you run on is written to disk. Formatting a .cpp updates names in that .cpp; run again on each .h to update header declarations (or use CLI input_dir / output_dir).


2.3 compile_args

Clang flags for virtual compile — must mirror how your project builds the same .c / .cpp file so the AST can be built.

Flag Why
-std=c++17 / -std=c++20 / … Language standard
-I... for every project and third-party header dir Missing -I → #include fails → run fails
-DNAME / -DNAME=value Macros your headers need

Does not need: -I for standard library (<vector>, <stdio.h>, …).

Copy -I and -D from CMake / MSBuild / your real build. On Windows JSON: "C:\\path".


2.4 Other parameters (brief)

Parameter Effect
clear_all_blank_lines_inside_function Collapse extra blank lines inside { ... } function bodies
cut_all_comments Strip almost all // and /* */ after rewrite (typical: remove AI boilerplate)
cut_all_comments_exception_substr_set Keep a comment only if its text contains a listed substring; requires cut_all_comments: true
force_braces_for_single_statement_after_condition if (x) foo(); → if (x) { foo(); }
blank_lines_between_fucntion_and_any_object Fixed blank-line count between top-level items; -1 = off

Extension setting (VS Code settings.json, not in clang-hesong.json): clang-hesong.configPath — path to config file (default .vscode/clang-hesong.json).

JSON → exe argument mapping:

JSON key Exe argument
naming_style naming_style=snake
compile_args one compile_arg=... per element
this_module_include_dirs this_module_include_dirs={dir1,dir2}
clear_all_blank_lines_inside_function clear_all_blank_lines_inside_function=true
cut_all_comments cut_all_comments=true
cut_all_comments_exception_substr_set cut_all_comments_exception_substr_set={a,b}
force_braces_for_single_statement_after_condition force_braces_for_single_statement_after_condition=true
blank_lines_between_fucntion_and_any_object blank_lines_between_fucntion_and_any_object=2

3. Quick start

  1. Open Folder — open your C/C++ project as a VS Code workspace.
  2. clang-hesong: Open Config — creates .vscode/clang-hesong.json; set "naming_style": "snake" (or "camel" / "pascal"), list your code roots in this_module_include_dirs, and replace C:\fake-dir1 placeholders in compile_args.
  3. clang-hesong: Run On This File — right-click a saved .cpp / .c / .h (Explorer or editor), or Ctrl+Shift+P → clang-hesong.

Output: View → Output → clang-hesong (start/end timestamps per file).
Bugs: GitHub Issues

3.1 Back up first

⚠️ Run On This File overwrites the target on disk (rename, comments, braces, blank lines). Commit in git, copy the file, or test on a throwaway branch before batch runs.

3.2 How it works (Clang)

The tool compiles one file with your compile_args (-std, every project/third-party -I, -D macros). Clang must resolve all #includes — same rules as your real build. Standard-library headers do not need extra -I.

Licensing: extension JS is MIT; bundled exe includes LLVM/Clang (Apache-2.0 WITH LLVM-exception).


4. Commands

Command Where What
clang-hesong: Open Config Explorer (any item) or editor (C/C++) Create/open .vscode/clang-hesong.json
clang-hesong: Run On This File Explorer or editor on .c/.cpp/.h/… Rewrite identifiers (and optional comment/brace/blank-line rules) in place

Run On This File only appears for C/C++ file extensions / language modes. If menus are missing: Reload Window and confirm extension clang-hesong is enabled.

4.1 Open Config — what you see

Situation What happens
No .vscode/clang-hesong.json yet Extension creates a template with placeholder paths C:\fake-dir1\..., C:\fake-dir2\... — not your machine’s real paths
File already exists Extension opens your existing file as-is — it never overwrites

To reset: delete .vscode/clang-hesong.json, then Open Config again.

This is not clang-format, Prettier, or a generic text formatter. It does not preview changes — it overwrites the file immediately. C/C++ only (.c, .cpp, .h, …).


5. Troubleshooting

Symptom Fix
Config must contain naming_style. Add "naming_style": "snake" (or "camel" / "pascal")
Config must contain a non-empty compile_args array. Add at least one -std and -I entry to compile_args
Bundled exe not found Reinstall extension; verify bin/win32-x64/clang-format-hesong.exe exists
No saved file is selected Save the file, then right-click it
Parse errors / file not found in output (missing -I) Add all include dirs from your real build to compile_args (see §2.3)
Parse errors in output (wrong -std or missing -D) Match your project’s compile flags in compile_args
Third-party or STL symbols wrongly renamed Narrow this_module_include_dirs — do not list third-party -I paths there (see §2.2)
After PascalCase, struct body looks corrupted (e.g. struct Applicationme …) Upgrade to 0.1.3+ — fixed incorrect member-reference rewrites on large files
After PascalCase, nlohmann::Json or json::parse breaks compile Upgrade to 0.1.3+ — type-alias and ::-qualified names are handled correctly
Link error LNK1561: entry point must be defined after rename Upgrade to 0.1.3+ — main is preserved; or restore from git and re-run
missing required parameters in exe output Ensure JSON has naming_style and non-empty compile_args
Windows only error This extension requires Windows x64

6. Third-party licenses

This extension is not affiliated with or endorsed by the LLVM Project.

Part License
VS Code extension (extension.js, docs) MIT — LICENSE
Bundled clang-format-hesong.exe (LLVM/Clang AST) Apache-2.0 WITH LLVM-exception — THIRD_PARTY_NOTICES.md

When redistributing the .vsix or installed package, keep both LICENSE and THIRD_PARTY_NOTICES.md.


7. Reporting issues

Report bugs and feature requests on GitHub (not the Marketplace Q&A).

All issues https://github.com/acidrainspace/clang-hesong-extension/issues
New issue https://github.com/acidrainspace/clang-hesong-extension/issues/new/choose

You need a free GitHub account to open an issue.

7.1 Steps

  1. Open New issue: https://github.com/acidrainspace/clang-hesong-extension/issues/new/choose
  2. Choose Bug report and fill in the form.
  3. Fill in environment, steps, config, and Output → clang-hesong log.
  4. Submit. We respond on GitHub; you can subscribe to email notifications on the thread.

7.2 What to include

Environment

  • VS Code version: Help → About
  • clang-hesong version: Extensions → clang-hesong (Publisher HeSong Tools)
  • Windows version (x64)

What happened — what you did, expected vs actual behavior.

Steps to reproduce — numbered list.

Configuration — paste .vscode/clang-hesong.json (redact paths if needed).

Output log — View → Output → clang-hesong → copy full text from the failed run.

Sample file (optional) — minimal .cpp / .h or steps to reproduce on a snippet.

7.3 Before you report

  • Check existing issues for duplicates.
  • Parse / -I errors: confirm compile_args (see §2.3).
  • Do not paste secrets into public issues.

8. Requirements

  • C/C++ source files (see scope above)
  • Windows x64
  • VS Code 1.90+
  • Valid compile_args: -std, all project/third-party -I paths, and any required -D macros (see §2.3)
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft