Refer to the documentation.
Basic Usage The easiest way to use CodeMirror is to simply load the
script and style sheet found under lib/ in the distribution, plus a
mode script from one of the mode/ directories. For example:
(Alternatively, use a
module loader. More about that later.)
Having done this, an editor instance can be created like this:
var myCodeMirror = CodeMirror(document.body); The editor will be
appended to the document body, will start empty, and will use the mode
that we loaded. To have more control over the new editor, a
configuration object can be passed to CodeMirror as a second argument:
var myCodeMirror = CodeMirror(document.body, { value: "function
myScript(){return 100;}\n", mode: "javascript" });
...