CodeMaiden for VS CodeA VS Code port of the beloved CodeMaiden Visual Studio extension. FeaturesCode Cleanup (
|
| Step | Default | Setting |
|---|---|---|
| Remove trailing whitespace | ✅ On | codemaiden.cleaning.removeTrailingWhitespace |
| Collapse multiple blank lines | ✅ On | codemaiden.cleaning.removeMultipleBlankLines |
| Ensure final newline | ✅ On | codemaiden.cleaning.ensureFinalNewline |
| Sort imports alphabetically | ❌ Off | codemaiden.cleaning.sortImports |
| Insert/replace file header | ❌ Off | codemaiden.fileHeader.enabled |
Sort Imports
Command: CodeMaiden: Sort Imports
Sorts import/using statements alphabetically. Language-aware:
- TypeScript / JavaScript — ES
importblocks - Python —
import/from … import, stdlib first - C# —
usingstatements,System.*first - Java / Kotlin —
importblocks
Join Lines (Ctrl+M Ctrl+J)
- No selection: joins the current line with the line below.
- With selection: collapses all selected lines into one.
Sort Selected Lines (Ctrl+M Ctrl+S)
Sorts the highlighted lines alphabetically (case-insensitive).
Auto-cleanup on Save
Click the $(sparkle) CodeMaiden button in the status bar (bottom-right) to toggle automatic cleanup every time you save a file. Or run CodeMaiden: Toggle Auto Cleanup on Save from the Command Palette.
File Header
When enabled (codemaiden.fileHeader.enabled: true), inserts a configurable header at the top of each file during cleanup.
Default template:
// File: {filename}
// Created: {date}
Available tokens: {filename}, {date}, {year}, {author}.
Commands
| Command | Keybinding | Description |
|---|---|---|
| CodeMaiden: Cleanup Document | Ctrl+M Ctrl+F |
Clean active file |
| CodeMaiden: Cleanup All Open Documents | — | Clean all dirty open files |
| CodeMaiden: Sort Imports | — | Sort imports in active file |
| CodeMaiden: Join Lines | Ctrl+M Ctrl+J |
Join line(s) |
| CodeMaiden: Sort Selected Lines | Ctrl+M Ctrl+S |
Sort selection |
| CodeMaiden: Toggle Auto Cleanup on Save | — | Toggle save-hook |
| CodeMaiden: Open Settings | — | Open CodeMaiden settings |
Supported Languages
By default, cleanup runs on:
TypeScript, JavaScript, TSX, JSX, C#, Python, Java, Go, Rust, C/C++, HTML, CSS, SCSS, LESS, JSON, XML, YAML, Markdown.
Customize with codemaiden.cleaning.languages.
Settings Reference
{
// Auto-clean on every save
"codemaiden.autoCleanupOnSave": false,
// ── Cleaning ──────────────────────────────────
"codemaiden.cleaning.removeTrailingWhitespace": true,
"codemaiden.cleaning.ensureFinalNewline": true,
"codemaiden.cleaning.removeMultipleBlankLines": true,
"codemaiden.cleaning.maxConsecutiveBlankLines": 1,
"codemaiden.cleaning.sortImports": false,
"codemaiden.cleaning.languages": ["typescript", "javascript", ...],
// ── File Header ───────────────────────────────
"codemaiden.fileHeader.enabled": false,
"codemaiden.fileHeader.template": "// File: {filename}\n// Created: {date}\n",
"codemaiden.fileHeader.author": ""
}
Inspiration
This extension is inspired by CodeMaiden by Steve Cadwallader,
a powerful open-source Visual Studio extension. CodeMaiden for VS Code brings the core cleanup
experience to VS Code with language-aware logic and a zero-dependency, pure TypeScript implementation.
License
MIT