# CodeMirror CodeMirror is a code editor that runs in the browser. It is written in JavaScript, released under the MIT license, and created by [[Marijn Haverbeke]]. If you use [[Obsidian]], you use CodeMirror every single day without knowing it. The Obsidian editor, including Live Preview and its whole set of Markdown niceties, is built on top of CodeMirror 6. That's why so many community plugins that change how text behaves while you type end up touching CodeMirror extensions directly. ## Why it matters Most people think of a text editor as a box you type into. CodeMirror treats it as a system: a document model, a set of state transactions, a view layer, and extensions that plug into all three. Nothing mutates in place. Every edit is a transaction that produces a new state. That design is the reason a note-taking app like [[Obsidian]] can layer syntax highlighting, folding, autocompletion, vim keybindings, and live rendering on the same editor without the whole thing collapsing under its own weight. ## CodeMirror 5 vs CodeMirror 6 CodeMirror 6 is not an upgrade of version 5. It's a rewrite: - Modular by default. You compose the editor from packages instead of enabling options on a monolith - Built with accessibility and screen readers in mind from the start - Full support for bidirectional and right-to-left text - Incremental parsing via Lezer, the parser system built alongside it - Collaborative editing primitives baked into the state model Version 5 is still out there in the wild in a lot of older tools. If you're reading plugin code and it looks nothing like the docs, check which major version you're actually on. ## Related projects by the same author CodeMirror sits in a family of tools that all share the same obsession with parsing and structured documents: - [[Lezer]], the incremental parser powering CodeMirror 6 syntax - [[Acorn]], the JavaScript parser used by a huge chunk of the JS tooling ecosystem - [[ProseMirror]], the structured rich-text editor - [[Wordgard]], the newer rich-text editor built from the lessons of [[ProseMirror]] It's worth noting that one person is behind all of those. That's a rare kind of leverage in [[Open Source]]. ## References - https://codemirror.net/ - https://lezer.codemirror.net/ - https://github.com/marijnh ## Related - [[Obsidian]] - [[Marijn Haverbeke]] - [[ProseMirror]] - [[Wordgard]] - [[Open Source]]