Skip to content
| Marketplace
Sign in
Visual Studio Code>Formatters>CMake FormatterNew to Visual Studio Code? Get it now.
CMake Formatter

CMake Formatter

Aleksandar Djordjevic

|
2 installs
| (0) | Free
Format CMake files using gersemi
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

CMake Formatter

A VS Code/Cursor extension that formats CMake files using gersemi.

Requirements

  • gersemi must be installed:
pip install gersemi

Features

  • Format CMake files (CMakeLists.txt and *.cmake)
  • Format on save support (enable editor.formatOnSave in VS Code settings)
  • Configurable line width and gersemi path

Extension Settings

Setting Description Default
cmakeFormatter.gersemiPath Path to the gersemi executable gersemi
cmakeFormatter.lineWidth Maximum line width for formatting 80

Usage

  1. Open a CMake file (CMakeLists.txt or *.cmake)
  2. Use Format Document command (Shift+Alt+F on Windows/Linux, Shift+Option+F on macOS)
  3. Or enable format on save in your settings:
{
  "editor.formatOnSave": true
}

Development

# Install dependencies
npm install

# Compile
npm run compile

# Watch for changes
npm run watch

# Package extension
npm run package
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft