.CodeMirror {border-top: 1px solid #eee; border-bottom: 1px solid #eee; line-height: 1.3; height: 500px} .CodeMirror-linenumbers { padding: 0 8px; }
CodeMirror
Home Manual Code
Sublime bindings
Sublime Text bindings demo
The sublime keymap defines many Sublime Text-specific bindings for CodeMirror. See the code below for an overview.
Enable the keymap by loading keymap/sublime.js and setting the keyMap option to "sublime" .
(A lot of the search functionality is still missing.)
var value = "// The bindings defined specifically in the Sublime Text mode\nvar bindings = {\n"; var map = CodeMirror.keyMap.sublime; for (var key in map) { var val = map[key]; if (key != "fallthrough" && val != "..." && (!/find/.test(val) || /findUnder/.test(val))) value += " \"" + key + "\": \"" + val + "\",\n"; } value += "}\n\n// The implementation of joinLines\n"; value += CodeMirror.commands.joinLines.toString().replace(/^function\s*\(/, "function joinLines(").replace(/\n /g, "\n") + "\n"; var editor = CodeMirror(document.body.getElementsByTagName("article")[0], { value: value, lineNumbers: true, mode: "javascript", keyMap: "sublime", autoCloseBrackets: true, matchBrackets: true, showCursorWhenSelecting: true, theme: "monokai", tabSize: 2 });