CodeMirror

# { } CodeMirror

    /* 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.

## Try the parser test pages:

- JavaScript
- XML/HTML
- CSS
- HTML mixed-mode
- SPARQL
- HTML+PHP mixed-mode
- Python
- Lua
- Ruby (unfinished)
- SQL
- PLSQL
- diff
- Groovy
- C#
- Scheme
- Java
- XQuery
- OmetaJS
- Freemarker
- Regular Expressions

## Some real-world uses:

- Google Earth KML sampler
- Google Code's in-browser patching
- Eloquent JavaScript's console
- The qooxdoo playground
- A cool tutorial about the <canvas> element
- An online IDE for the Orc programming language
- Google's API playground
- Raphaël Live
- JS Bin
- The RokPad plugin for Joomla
- The scraperwiki editor
- jsLinb UI Builder
- ZK CodeMirror component (demo)
- 'Zen Coding' on top of CodeMirror
- Web-based MySQL administration

## Supported browsers

The following browsers are able to run CodeMirror:

- Firefox 1.5 or higher
- Internet Explorer 6 or higher
- Safari 3 or higher
- Opera 9.52 or higher
- Chrome

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.

## Getting the code

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.

## Documentation

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.

## Support

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.

Download the latest release

## Make a donation

- Paypal
- Bank

Bank: Rabobank
Country: Netherlands
SWIFT: RABONL2U
Account: 147850770
Name: Marijn Haverbeke
IBAN: NL26 RABO 0147 8507 70

## Releases:

17-02-2011: Version 0.94:

- `tabMode: "spaces"` was modified slightly (now indents when something is selected).
- Fixes a bug that would cause the selection code to break on some IE versions.
- Disabling spell-check on WebKit browsers now works.

08-02-2011: Version 2.0 beta 1:

CodeMirror 2 is a complete rewrite of CodeMirror, no longer depending on an editable frame.

19-01-2011: Version 0.93:

- Added a Regular Expression parser.
- Fixes to the PHP parser.
- Support for regular expression in search/replace.
- Add `save` method to instances created with `fromTextArea`.
- Add support for MS T-SQL in the SQL parser.
- Support use of CSS classes for highlighting brackets.
- Fix yet another hang with line-numbering in hidden editors.

17-12-2010: Version 0.92:

- Make CodeMirror work in XHTML documents.
- Fix bug in handling of backslashes in Python strings.
- The `styleNumbers` option is now officially supported and documented.
- `onLineNumberClick` option added.
- More consistent names `onLoad` and `onCursorActivity` callbacks. Old names still work, but are deprecated.
- Add a Freemarker mode.

11-11-2010: Version 0.91:

- Adds support for Java.
- Small additions to the PHP and SQL parsers.
- Work around various Webkit issues.
- Fix `toTextArea` to update the code in the textarea.
- Add a `noScriptCaching` option (hack to ease development).
- Make sub-modes of HTML mixed mode configurable.

02-10-2010: Version 0.9:

- Add support for searching backwards.
- There are now parsers for Scheme, XQuery, and OmetaJS.
- Makes `height: "dynamic"` more robust.
- Fixes bug where paste did not work on OS X.
- Add a `enterMode` and `electricChars` options to make indentation even more customizable.
- Add `firstLineNumber` option.
- Fix bad handling of `@media` rules by the CSS parser.
- Take a new, more robust approach to working around the invisible-last-line bug in WebKit.

22-07-2010: Version 0.8:

- Add a `cursorCoords` method to find the screen coordinates of the cursor.
- A number of fixes and support for more syntax in the PHP parser.
- Fix indentation problem with JSON-mode JS parser in Webkit.
- Add a minification UI.
- Support a `height: dynamic` mode, where the editor's height will adjust to the size of its content.
- Better support for IME input mode.
- Fix JavaScript parser getting confused when seeing a no-argument function call.
- Have CSS parser see the difference between selectors and other identifiers.
- Fix scrolling bug when pasting in a horizontally-scrolled editor.
- Support `toTextArea` method in instances created with `fromTextArea`.
- Work around new Opera cursor bug that causes the cursor to jump when pressing backspace at the end of a line.