Live-blogging Marijn Haverbeke, creator of CodeMirror, at Full Frontal.

Code editors:

When create Eloquent JavaScript, Marijn wanted to show code cleanly.

ACE - formerly Bespin - was faster and more portable, making CodeMirror look bad! So CodeMirror 2 is a rewrite based on some of those techniques.

Some performance tricks:

  • Indexes both by line number and by vertical offset.
  • Only renders the portion of the DOM you can see, plus a little on either side in case you scroll just a few lines.
  • Selections are passed back to the original text area.

Hijacking browser key events is tricky, browsers don’t always let JavaScript capture events. Chrome has an open bug to let scripts override keyboard.