From the docs:
Behave.js is a lightweight library for adding IDE style behaviors to plain text areas, making it much more enjoyable to write code in.
I’ve always been really frustrated by WYSIWYG editor’s ‘HTML mode’ – I think it would be interesting to combine Behave.js with something like Medium.js for the ultimate in-browser text editing domination.
Behave.js is MIT licensed. Source code on GitHub.