首页 > 代码库 > (二)CodeMirror - 配置项

(二)CodeMirror - 配置项

theme: string

theme:‘monokai‘  

引入对应的css, <link rel="stylesheet" href="http://www.mamicode.com/theme/monokai.css">

indentUnit: integer

缩进,默认2

keyMap: string

keyMap: "sublime"  使用sublime中快捷键

引入对应的js, <script src="http://www.mamicode.com/keymap/sublime.js"></script>

extraKeys: object

自定义快捷键

extraKeys: {"Ctrl-Q": "autocomplete"}

需引入:

<script src="http://www.mamicode.com/addon/hint/show-hint.js"></script>
<script src="http://www.mamicode.com/addon/hint/javascript-hint.js"></script>
<link rel="stylesheet" href="http://www.mamicode.com/addon/hint/show-hint.css">

// 使用tab键
extraKeys: {
"Tab": function(cm){ var spaces = Array(cm.getOption("indentUnit") + 1).join(" "); cm.replaceSelection(spaces); }}

gutters: array<string>

自定义lineNumber

gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter","CodeMirror-lint-markers"]

  CodeMirror-foldgutter:展开收起

  需引入:

    <link rel="stylesheet" href="http://www.mamicode.com/addon/fold/foldgutter.css" />

    <script src="http://www.mamicode.com/addon/fold/foldcode.js"></script>

    <script src="http://www.mamicode.com/addon/fold/brace-fold.js"></script>

    <script src="http://www.mamicode.com/addon/fold/brace-fold.js"></script>

   CodeMirror-lint-markers:代码错误检测

  需引入:

  <script src="http://ajax.aspnetcdn.com/ajax/jshint/r07/jshint.js"></script>

  <script src="http://rawgithub.com/zaach/jsonlint/79b553fb65c192add9066da64043458981b3972b/lib/jsonlint.js"></script>

  <script src="http://rawgithub.com/stubbornella/csslint/master/release/csslint.js"></script>

  <script src="http://www.mamicode.com/addon/lint/lint.js"></script>

  <script src="http://www.mamicode.com/addon/lint/javascript-lint.js"></script>

  <script src="http://www.mamicode.com/addon/lint/json-lint.js"></script>

  <script src="http://www.mamicode.com/addon/lint/css-lint.js"></script>

  <link rel="stylesheet" href="http://www.mamicode.com/addon/lint/lint.css">

 

(二)CodeMirror - 配置项