/* 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 parser has been written for the language you are editing (see below for a list of supported languages), the code will be coloured, and the editor will help you with indentation.
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 below for information on how to contact me.
All of CodeMirror is released under a zlib-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: http://github.com/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 all of the (many) options and methods that CodeMirror exposes.
For those who want to learn more about the code, this document about CodeMirror's architecture will be useful. The source code itself is, for the most part, also very well commented.
There is a Google group (a sort of mailing list/newsgroup thing) for discussion and news related to CodeMirror. Please check the FAQ before asking a question. You can also e-mail me directly: Marijn Haverbeke.
19-01-2011: Version 0.93:
save
method to instances created with fromTextArea
.17-12-2010: Version 0.92:
styleNumbers
option is now officially
supported and documented.onLineNumberClick
option added.onLoad
and
onCursorActivity
callbacks. Old names still work, but
are deprecated.11-11-2010: Version 0.91:
toTextArea
to update the code in the textarea.noScriptCaching
option (hack to ease development).02-10-2010: Version 0.9:
height: "dynamic"
more robust.enterMode
and electricChars
options to make indentation even more customizable.firstLineNumber
option.@media
rules by the CSS parser.22-07-2010: Version 0.8:
cursorCoords
method to find the screen
coordinates of the cursor.height: dynamic
mode, where the editor's
height will adjust to the size of its content.toTextArea
method in instances created with
fromTextArea
.27-04-2010: Version 0.67:
More consistent page-up/page-down behaviour
across browsers. Fix some issues with hidden editors looping forever
when line-numbers were enabled. Make PHP parser parse
"\\"
correctly. Have jumpToLine
work on
line handles, and add cursorLine
function to fetch the
line handle where the cursor currently is. Add new
setStylesheet
function to switch style-sheets in a
running editor.