# { } 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 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.

## Supported modes:

- C, Java, C#, and similar
- Clojure
- CoffeeScript
- CSS
- diff
- Groovy
- Haskell
- HTML mixed-mode
- JavaScript
- Jinja2
- Lua
- Markdown (Github-flavour)
- NTriples
- Pascal
- Perl
- PHP
- PL/SQL
- Python
- R
- RPM spec and changelog
- reStructuredText
- Ruby
- Rust
- Scheme
- Smalltalk
- SPARQL
- sTeX, LaTeX
- Tiddlywiki
- Velocity
- XML/HTML (alternative XML)
- YAML

## Usage demos:

- Autocompletion
- Mode overlays
- Search/replace
- Code folding
- HTML editor with preview
- Auto-resizing editor
- Setting breakpoints
- Highlighting the current line
- Theming
- Stand-alone highlighting
- Full-screen editing
- Mode auto-changing

## Getting the code

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.

## 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, there is an overview of the internals available. The source code itself is, for the most part, also well commented.

## Support and bug reports

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.

## Supported browsers

The following browsers are able to run CodeMirror:

- Firefox 2 or higher
- Chrome, any version
- Safari 3 or higher
- Internet Explorer 6 or higher
- Opera 9 or higher (with some key-handling problems on OS X)

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.

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:

21-11-2011: Version 2.18:

Fixes `TextMarker.clear`, which is broken in 2.17.

21-11-2011: Version 2.17:

- Add support for line wrapping and code folding.
- Add Github-style Markdown mode.
- Add Monokai and Rubyblue themes.
- Add `setBookmark` method.
- Move some of the demo code into reusable components under `lib/util`.
- Make screen-coord-finding code faster and more reliable.
- Fix drag-and-drop in Firefox.
- Improve support for IME.
- Speed up content rendering.
- Fix browser's built-in search in Webkit.
- Make double- and triple-click work in IE.
- Various fixes to modes.

27-10-2011: Version 2.16:

- Add Perl, Rust, TiddlyWiki, and Groovy modes.
- Dragging text inside the editor now moves, rather than copies.
- Add a `coordsFromIndex` method.
- API change: `setValue` now no longer clears history. Use `clearHistory` for that.
- API change: `markText` now returns an object with `clear` and `find` methods. Marked text is now more robust when edited.
- Fix editing code with tabs in Internet Explorer.

26-09-2011: Version 2.15:

Fix bug that snuck into 2.14: Clicking the character that currently has the cursor didn't re-focus the editor.

26-09-2011: Version 2.14:

- Add Clojure, Pascal, NTriples, Jinja2, and Markdown modes.
- Add Cobalt and Eclipse themes.
- Add a `fixedGutter` option.
- Fix bug with `setValue` breaking cursor movement.
- Make gutter updates much more efficient.
- Allow dragging of text out of the editor (on modern browsers).

23-08-2011: Version 2.13:

- Add Ruby, R, CoffeeScript, and Velocity modes.
- Add `getGutterElement` to API.
- Several fixes to scrolling and positioning.
- Add `smartHome` option.
- Add an experimental pure XML mode.

25-07-2011: Version 2.12:

- Add a SPARQL mode.
- Fix bug with cursor jumping around in an unfocused editor in IE.
- Allow key and mouse events to bubble out of the editor. Ignore widget clicks.
- Solve cursor flakiness after undo/redo.
- Fix block-reindent ignoring the last few lines.
- Fix parsing of multi-line attrs in XML mode.
- Use `innerHTML` for HTML-escaping.
- Some fixes to indentation in C-like mode.
- Shrink horiz scrollbars when long lines removed.
- Fix width feedback loop bug that caused the width of an inner DIV to shrink.

04-07-2011: Version 2.11:

- Add a Scheme mode.
- Add a `replace` method to search cursors, for cursor-preserving replacements.
- Make the C-like mode mode more customizeable.
- Update XML mode to spot mismatched tags.
- Add `getStateAfter` API and `compareState` mode API methods for finer-grained mode magic.
- Add a `getScrollerElement` API method to manipulate the scrolling DIV.
- Fix drag-and-drop for Firefox.
- Add a C# configuration for the C-like mode.
- Add full-screen editing and mode-changing demos.

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:

- Add a Lua mode.
- Fix reverse-searching for a regexp.
- Empty lines can no longer break highlighting.
- Rework scrolling model (the outer wrapper no longer does the scrolling).
- Solve horizontal jittering on long lines.
- Add runmode.js.
- Immediately re-highlight text when typing.
- Fix problem with 'sticking' horizontal scrollbar.

Older releases...