/* In-browser code editing made bearable */
CodeMirror is a JavaScript library that can be used to create a relatively pleasant editor interface for code-like content ― computer programs, HTML markup, and similar. If a mode has been written for the language you are editing, the code will be coloured, and the editor will optionally help you with indentation.
This is the project page for CodeMirror 2, the currently more actively developed, and recommended version. CodeMirror 1 is still available from here.
All of CodeMirror is released under a MIT-style license. To get it, you can download the latest release or the current development snapshot as zip files. To create a custom minified script file, you can use the compression API.
We use git for version control. The main repository can be fetched in this way:
git clone http://marijnhaverbeke.nl/git/codemirror2
CodeMirror can also be found on GitHub at marijnh/CodeMirror2. If you plan to hack on the code and contribute patches, the best way to do it is to create a GitHub fork, and send pull requests.
The manual is your first stop for learning how to use this library. It starts with a quick explanation of how to use the editor, and then describes all of the (many) options and methods that CodeMirror exposes.
For those who want to learn more about the code, there is an overview of the internals available. The source code itself is, for the most part, also well commented.
There is a Google group (a sort of mailing list/newsgroup thing) for discussion and news related to CodeMirror. Reporting bugs is best done on github. You can also e-mail me directly: Marijn Haverbeke.
The following browsers are able to run CodeMirror:
I am not actively testing against every new browser release, and vendors have a habit of introducing bugs all the time, so I am relying on the community to tell me when something breaks. See here for information on how to contact me.
25-07-2011: Version 2.12:
innerHTML
for HTML-escaping.04-07-2011: Version 2.11:
replace
method to search cursors, for cursor-preserving replacements.getStateAfter
API and compareState
mode API methods for finer-grained mode magic.getScrollerElement
API method to manipulate the scrolling DIV.07-06-2011: Version 2.1:
Add a theme system (demo). Note that this is not backwards-compatible—you'll have to update your styles and modes!
07-06-2011: Version 2.02:
26-05-2011: Version 2.01:
coordsChar
now worksonCursorActivity
interfered with onChange
.onChange
."nocursor"
mode for readOnly
option.onHighlightComplete
option.