# CodeMirror

## In-browser code editing made slightly less painful

CodeMirror is a JavaScript program 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 (we currently have JavaScript, XML, CSS, PHP, and SPARQL covered), the code will be prettily coloured, and indentation will be taken care of for you, meaning the cursor will be placed at the right position when you press enter, and it is possible to re-indent blocks of code automatically.

To get a look at CodeMirror, see the test pages for the various parsers...

- JavaScript
- XML/HTML
- CSS
- SPARQL
- HTML mixed-mode
- HTML+PHP mixed-mode (courtesy of Yahoo!)

Or take a look at some real-world uses of the system...

- FireRainbow: syntax colouring for Firebug
- Freebase's Acre IDE
- Google Earth KML sampler
- 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

## Releases

04-03-2008: Version 0.61: Add line numbers support (see `lineNumbers` option in manual). Support a mode where tab 'shifts' indentation instead of resetting it (see `tabMode="shift"`). Add `indentUnit` option to configure indentation depths. Make it possible to grab the editor's keyboard input, which is useful when popping up dialogs (see `grabKeys`/`ungrabKeys`). Fix a lot of small bugs, among which the various issues related to pasting in Internet Explorer.

29-12-2008: Version 0.60: This release makes lots of internal changes, so test before you upgrade. More robust selection-preservation on IE, allowing styles with different font sizes. New `activeTokens` and `cursorActivity` callbacks, and a more powerful, line-based interface for inspecting and manipulating the content of the editor (see manual). Fixes the `replaceSelection` problem in IE, and a lot of other, smaller issues.

28-09-2008: Version 0.58: Add parsers for SPARQL and HTML-mixed-mode (nests CSS and JS parsers). Also: bracket highlighting, a 'dumb tabs' mode, an `onChange` callback, and heaps of bugfixes. See the manual for details on the new features.

04-07-2008: Version 0.57: A CSS parser and a nice tokenizer framework, bugfixes in the XML parser, a few browser-issue workarounds, one of which should fix the age-old Firefox cursor-showing-on-wrong line bug.

25-04-2008: Version 0.56: Fixes for some minor bugs, no new features.

30-03-2008: Version 0.55: Fixes a bug that broke redo, adds `readOnly` option.

10-03-2008: Version 0.54: Some new utility functions and options (see `fromTextArea`, `saveFunction`, `initCallback`, `textWrapping`, `disableSpellcheck`, `jumpToLine`, and `reindent` in the manual), many bugfixes, and some cleaning up and shrinking of the codebase (MochiKit is no longer used).

26-01-2008: Version 0.53: Adds support for continuous scanning, search/replace, undo/redo, jump-to-line, selection getting and setting. See the manual for details. Also fixes a bucket of bugs.

## Supported browsers

At this time, the following browsers are supported:

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

Making it work on other browsers that have decent support for the W3C DOM model should not be too hard, but I am not actively testing against those.

## Getting the code

All of CodeMirror is released under a BSD-style license. To get it, you can download the latest release or the current development snapshot as zip files, or use the darcs version control system to get the repository:

    darcs get http://marijn.haverbeke.nl/codemirror

This second method is recommended if you are planning to hack on CodeMirror ― it makes it easy to record your patches and share them with me. To see the repository online, visit the CodeMirror darcsweb.

## Support

There is a Google group (a sort of mailing list/newsgroup thingy) for discussion and news related to CodeMirror. You can also e-mail me directly: Marijn Haverbeke.

## Documentation

- The manual is all most users will need to read (or skim).
- If you're interested in working on the code, this document about CodeMirror's architecture will be useful.
- The source code is, for the most part, rather well commented, so if all else fails, you can try reading it.