A standalone, modular packaging of the original CodeMirror formatting addon (v1.0.0), designed to simplify inclusion in module-based projects. Originally extracted from the official CodeMirror v2 demo page, this package provides basic code formatting capabilities (auto-indent and comment toggling) for CodeMirror editors. The release cadence is low; the package has been stable since 2016. Unlike the built-in formatting in CodeMirror v5+, this addon is compatible with older CodeMirror versions (2.x) and does not require a full migration. It ships as a single JavaScript file and is intended for use with browser module loaders or bundlers.
npm install codemirror-formattingVerified import paths — ran on the pinned version, not inferred.
Shows how to import the formatting addon and use its commands (indentMore, indentLess, autoIndent, toggleComment) on a CodeMirror editor.
Upgrade to CodeMirror v5+ and use its built-in formatting commands (e.g., indentMore, indentLess).
Ensure this import is only done once in your application.
Consider using the official CodeMirror formatting addon from @codemirror/format or codemirror/addon/comment/comment.js.
Test with your specific mode or use a mode that defines indentUnit.
Run npm install codemirror-formatting or add it to package.json.
Ensure CodeMirror is imported and available globally (e.g., import 'codemirror' before 'codemirror-formatting').
Verify that the addon is imported and that you are using a compatible CodeMirror version (2.x–4.x).