Skip to content
| Marketplace
Sign in
Visual Studio Code>Formatters>C++ Header FactoryNew to Visual Studio Code? Get it now.
C++ Header Factory

C++ Header Factory

kxigor

|
49 installs
| (0) | Free
Dynamic header comments for C++ with auto-sizing
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

C++ Header Factory

Generate perfectly aligned section-header comments for C/C++ — the fill characters size themselves automatically.

Stop counting = signs by hand. Put the cursor where you want a header, type a title, and get a comment that is exactly the right width, with the size shrinking automatically for nested scopes.

class MyClass {
  /*====================== Usings/Helpers ======================*/
  class Helper {
    /*===== Private Methods ======*/
    void method() {
      /*== locals ==*/
    }
  };
};

Usage

  1. Place the cursor on the (empty) line where you want the header.
  2. Press Ctrl+Shift+7 (Cmd+Shift+7 on macOS), or run C++ Header Factory: Insert C++ Header Comment from the Command Palette.
  3. Type the section title and press Enter.

The header is inserted at the cursor — no extra blank line is added.

Features

  • Auto-sizing — fill characters expand/shrink so every header is the same width.
  • Nesting-aware — deeper scopes get smaller headers automatically (based on indentation).
  • Fully customizable look — fill character, comment style, alignment, padding, letter case, and the gap after the comment marker.
  • Unicode / emoji safe — multi-byte fills like 🌸 are never cut in half.

Customization examples

Comment style & fill character (commentStyle, fillCharacter):

/*================== Section ===================*/   // default block + "="
//=================== Section ====================   // commentStyle = line
/*------------------ Section -------------------*/   // fillCharacter = "-"
//******************* Section ********************   // line + "*"
/*-=-=-=-=-=-=-=-=-= Section -=-=-=-=-=-=-=-=-=-*/   // fillCharacter = "-="

Letter case (titleCase):

/*=========== memory pool ============*/   // none  (as typed)
/*=========== MEMORY POOL ============*/   // upper
/*=========== Memory Pool ============*/   // title

Alignment (alignment):

/*============= Helpers ==============*/   // center
/* Helpers ===========================*/   // left
/*=========================== Helpers */   // right

Padding — spaces around the title (padding):

/*===========Pad============*/   // padding = 0
/*========== Pad ===========*/   // padding = 1 (default)
/*========   Pad   =========*/   // padding = 3

Marker gap — text inserted right after // or /* (markerGap):

// ================ Helpers ================   // markerGap = " "  (line)
/* ============== Helpers =============== */   // markerGap = " "  (block)

Emoji — use any string as the fill or marker gap:

//🌸 ============== Config ==============     // markerGap = "🌸 "
// 🌸 ------------- Config --------------     // markerGap = " 🌸 ", fill = "-"
//✦✦✦✦✦✦✦✦✦✦✦✦✦✦✦✦ TODO ✦✦✦✦✦✦✦✦✦✦✦✦✦✦✦✦     // fill = "✦", upper

Note: widths are counted in characters. Emoji usually render two columns wide in monospace fonts, so emoji headers may not line up pixel-perfectly even though the character count is exact.

Settings

All settings live under cppHeaderFactory.*.

Setting Type Default Description
baseLength number 64 Total width of a top-level header, including the comment markers and title.
fillCharacter string "=" Character(s) used to fill the header. A single char (=, -, *, #, 🌸) or a repeating pattern (-=).
commentStyle block | line block block → /* … */, line → // ….
titleCase none | upper | title none Letter-case transform applied to the title.
alignment center | left | right center Where the title sits within the header.
padding number 1 Spaces between the fill and the title.
markerGap string "" Text inserted between the comment marker and the fill. Set to " " for // ===== Title =====, or any custom string.
nestingReduction number 2 Width-reduction factor per nesting level (set to 1 to disable shrinking).
sameSizeForLevelZeroAndOne boolean true Use the same width for global scope and the first nesting level.
indentSize number 2 Leading-whitespace characters per nesting level. Use 2/4 for spaces, or 1 if you indent with tabs.
maxNestingLevel number 5 Deepest level the auto-sizing counts to (deeper indentation is clamped).

How auto-sizing works

  1. The nesting level is detected from the line's indentation: level = 1 + floor(indentChars / indentSize), clamped to maxNestingLevel.
  2. The target width starts at baseLength and is divided by nestingReduction ^ (level − 1) for nested scopes (with sameSizeForLevelZeroAndOne collapsing levels 0 and 1).
  3. The title is laid out to that exact width, distributing the fill characters according to alignment and padding.

Development

npm install
npm run compile   # type-check, lint, bundle
npm test          # run the test suite in a VS Code test host

License

MIT

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft