/* In-browser code editing made bearable */
CodeMirror is a JavaScript component that provides a code editor in the browser. When a mode is available for the language you are coding in, it will color your code, and optionally help with indentation.
A rich programming API and a CSS theming system are available for customizing CodeMirror to fit your application, and extending it with new functionality.
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/codemirror
CodeMirror can also be found on GitHub at marijnh/CodeMirror. 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 the API in detail.
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.
Community discussion, questions, and informal bug reporting is done on the CodeMirror Google group. There is a separate group, CodeMirror-announce, which is lower-volume, and is only used for major announcements—new versions and such. These will be cross-posted to both groups, so you don't need to subscribe to both.
Though bug reports through e-mail are responded to, the preferred way to report bugs is to use the Github issue tracker. Before reporting a bug, read these pointers. Also, the issue tracker is for bugs, not requests for help.
When none of these seem fitting, you can simply e-mail the maintainer directly.
The following desktop browsers are able to run CodeMirror:
<!doctype
html>
is recommended.)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.
Mobile browsers mostly kind of work, but, because of limitations and their fundamentally different UI assumptions, show a lot of quirks that are hard to work around.
CodeMirror is developed and maintained by me, Marijn Haverbeke, in my own time. If your company is getting value out of CodeMirror, please consider purchasing a support contract.
CodeMirror support contracts exist in two forms—basic at €100 per month, and premium at €500 per month. Contact me for further information.
19-09-2012: Version 2.34:
compareStates
is no longer needed.onHighlightComplete
no longer works.CodeMirror.version
property.19-09-2012: Version 3.0, beta 1:
BETA release, new major version. Only partially backwards-compatible. See the upgrading guide for more information. Major new features are:
23-08-2012: Version 2.33:
getViewPort
and onViewportChange
API.false
disabling handling (again).innerHTML
. Remove CodeMirror.htmlEscape
.23-07-2012: Version 2.32:
Emergency fix for a bug where an editor with line wrapping on IE will break when there is no scrollbar.
20-07-2012: Version 2.31:
setSize
method for programmatic resizing.getHistory
and setHistory
methods.getValue
and getRange
.22-06-2012: Version 2.3:
getScrollInfo
method.23-05-2012: Version 2.25:
23-04-2012: Version 2.24:
dragDrop
and onDragEvent
options.compoundChange
API method.catchall
in key maps,
add nofallthrough
boolean field instead.26-03-2012: Version 2.23:
setLineClass
.charCoords
and cursorCoords
with a mode
argument.autofocus
option.findMarksAt
method.27-02-2012: Version 2.22:
autoClearEmptyLines
option.27-01-2012: Version 2.21:
smartIndent
option.readOnly
-mode.scrollTo
method.20-12-2011: Version 2.2:
coordsFromIndex
to posFromIndex
,
add indexFromPos
method.