# { } CodeMirror

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

## Supported modes:

- C, C++, C#
- Clojure
- CoffeeScript
- Common Lisp
- CSS
- D
- diff
- ECL
- Erlang
- Go
- Groovy
- Haskell
- Haxe
- HTML mixed-mode
- HTTP
- Java
- JavaScript
- LESS
- Lua
- Markdown (GitHub-flavour)
- NTriples
- OCaml
- Pascal
- Perl
- PHP
- Properties files
- Python
- R
- reStructuredText
- Ruby
- Rust
- Sass
- Scala
- Scheme
- Shell
- Smalltalk
- Smarty
- SQL (several dialects)
- SPARQL
- sTeX, LaTeX
- VB.NET
- VBScript
- Velocity
- XML/HTML
- XQuery
- YAML
- Z80
- Full list...

## Usage demos:

- Autocompletion (XML)
- Search/replace
- Code folding
- Line widgets (via JSHint)
- Mode overlays
- Mode multiplexer
- HTML editor with preview
- Auto-resizing editor
- Setting breakpoints
- Highlighting the current line
- Highlighting selection matches
- Theming
- Mixed font sizes
- Stand-alone highlighting
- Full-screen editing
- Mode auto-changing
- Visible tabs
- Autoformatting of code
- Emacs keybindings
- Vim keybindings
- Automatic xml tag closing
- Lazy mode loading
- Document tree visualization

## Real-world uses:

- jsbin.com (JS playground)
- Light Table (experimental IDE)
- Adobe Brackets (code editor)
- Mergely (interactive diffing)
- Google Apps Script
- GitHub's Android app
- Eloquent JavaScript (book)
- Zen Coding (fast XML editing)
- Paper.js (graphics scripting)
- Codev (collaborative IDE)
- Tributary (augmented editing)
- Prose.io (github content editor)
- WeScheme (learning tool)
- WebGL playground
- ql.io (http API query helper)
- The File Tree (collab editor)
- JSHint (JS linter)
- SQLFiddle (SQL playground)
- Try Haxe (Haxe Playground)
- CSSDeck (CSS showcase)
- sketchPatch Livecodelab
- NoTex (rST authoring)
- More...

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

## 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 the API in detail.

For those who want to learn more about the code, there is a series of posts on CodeMirror on my blog, and the old overview of the editor internals. The source code itself is, for the most part, also very readable.

## Support and bug reports

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.

## Supported browsers

The following desktop browsers are able to run CodeMirror:

- Firefox 3 or higher
- Chrome, any version
- Safari 5.2 or higher
- Opera 9 or higher (with some key-handling problems on OS X)
- Internet Explorer 8 or higher in standards mode
  (Not quirks mode. But quasi-standards mode with a transitional doctype is also flaky. `<!doctype html>` is recommended.)
- Internet Explorer 7 (standards mode) is usable, but buggy. It has a z-index bug that prevents CodeMirror from working properly.

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.

## Commercial support

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.

- You'll be funding further work on CodeMirror.
- You ensure that you get a quick response when you have a problem, even when I am otherwise busy.

CodeMirror support contracts exist in two forms???basic at ???100 per month, and premium at ???500 per month. Contact me for further information.

Download the latest release

## Support CodeMirror

- Donate (Paypal, bank, or Gittip)
- Purchase commercial support

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

## Reading material

- User manual
- Browse the code

## Releases

21-01-2013: Version 3.01:

- Move all add-ons into an organized directory structure under `/addon`. You might have to adjust your paths.
- New modes: D, Sass, APL, SQL (configurable), and Asterisk.
- Several bugfixes in right-to-left text support.
- Add `rtlMoveVisually` option.
- Improvements to vim keymap.
- Add built-in (lightweight) overlay mode support.
- Support `showIfHidden` option for line widgets.
- Add simple Python hinter.
- Bring back the `fixedGutter` option.
- Full list of patches.

21-01-2013: Version 2.38:

Integrate some bugfixes, enhancements to the vim keymap, and new modes (D, Sass, APL) from the v3 branch.

20-12-2012: Version 2.37:

- New mode: SQL (will replace plsql and mysql modes).
- Further work on the new VIM mode.
- Fix Cmd/Ctrl keys on recent Operas on OS X.
- Full list of patches.

10-12-2012: Version 3.0:

New major version. Only partially backwards-compatible. See the upgrading guide for more information. Changes since release candidate 2:

- Rewritten VIM mode.
- Fix a few minor scrolling and sizing issues.
- Work around Safari segfault when dragging.
- Full list of patches.

20-11-2012: Version 3.0, release candidate 2:

- New mode: HTTP.
- Improved handling of selection anchor position.
- Improve IE performance on longer lines.
- Reduce gutter glitches during horiz. scrolling.
- Add `addKeyMap` and `removeKeyMap` methods.
- Rewrite `formatting` and `closetag` add-ons.
- Full list of patches.

20-11-2012: Version 2.36:

- New mode: Z80 assembly.
- New theme: Twilight.
- Add command-line compression helper.
- Make `scrollIntoView` public.
- Add `defaultTextHeight` method.
- Various extensions to the vim keymap.
- Make PHP mode build on mixed HTML mode.
- Add comment-continuing add-on.
- Full list of patches.

20-11-2012: Version 3.0, release candidate 1:

- New theme: Solarized.
- Introduce `addLineClass` and `removeLineClass`, drop `setLineClass`.
- Add a lot of new options for marked text (read-only, atomic, collapsed, widget replacement).
- Remove the old code folding interface in favour of these new ranges.
- Add `isClean`/`markClean` methods.
- Remove `compoundChange` method, use better undo-event-combining heuristic.
- Improve scrolling performance smoothness.
- Full list of patches.

22-10-2012: Version 2.35:

- New (sub) mode: TypeScript.
- Don't overwrite (insert key) when pasting.
- Fix several bugs in `markText`/undo interaction.
- Better indentation of JavaScript code without semicolons.
- Add `defineInitHook` function.
- Full list of patches.

22-10-2012: Version 3.0, beta 2:

- Fix page-based coordinate computation.
- Fix firing of `gutterClick` event.
- Add `cursorHeight` option.
- Fix bi-directional text regression.
- Add `viewportMargin` option.
- Directly handle mousewheel events (again, hopefully better).
- Make vertical cursor movement more robust (through widgets, big line gaps).
- Add `flattenSpans` option.
- Many optimizations. Poor responsiveness should be fixed.
- Initialization in hidden state works again.
- Full list of patches.

19-09-2012: Version 2.34:

- New mode: Common Lisp.
- Fix right-click select-all on most browsers.
- Change the way highlighting happens:
  Saves memory and CPU cycles.
  `compareStates` is no longer needed.
  `onHighlightComplete` no longer works.
- Integrate mode (Markdown, XQuery, CSS, sTex) tests in central testsuite.
- Add a `CodeMirror.version` property.
- More robust handling of nested modes in formatting and closetag plug-ins.
- Un/redo now preserves marked text and bookmarks.
- Full list of patches.

19-09-2012: Version 3.0, beta 1:

- Bi-directional text support.
- More powerful gutter model.
- Support for arbitrary text/widget height.
- In-line widgets.
- Generalized event handling.

23-08-2012: Version 2.33:

- New mode: Sieve.
- New `getViewPort` and `onViewportChange` API.
- Configurable cursor blink rate.
- Make binding a key to `false` disabling handling (again).
- Show non-printing characters as red dots.
- More tweaks to the scrolling model.
- Expanded testsuite. Basic linter added.
- Remove most uses of `innerHTML`. Remove `CodeMirror.htmlEscape`.
- Full list of patches.

Older releases...