sublime.html 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <!doctype html>
  2. <title>CodeMirror: Sublime Text bindings demo</title>
  3. <meta charset="utf-8"/>
  4. <link rel=stylesheet href="../doc/docs.css">
  5. <link rel="stylesheet" href="../lib/codemirror.css">
  6. <link rel="stylesheet" href="../addon/fold/foldgutter.css">
  7. <link rel="stylesheet" href="../addon/dialog/dialog.css">
  8. <link rel="stylesheet" href="../theme/monokai.css">
  9. <script src="../lib/codemirror.js"></script>
  10. <script src="../addon/search/searchcursor.js"></script>
  11. <script src="../addon/search/search.js"></script>
  12. <script src="../addon/dialog/dialog.js"></script>
  13. <script src="../addon/edit/matchbrackets.js"></script>
  14. <script src="../addon/edit/closebrackets.js"></script>
  15. <script src="../addon/comment/comment.js"></script>
  16. <script src="../addon/wrap/hardwrap.js"></script>
  17. <script src="../addon/fold/foldcode.js"></script>
  18. <script src="../addon/fold/brace-fold.js"></script>
  19. <script src="../mode/javascript/javascript.js"></script>
  20. <script src="../keymap/sublime.js"></script>
  21. <style type="text/css">
  22. .CodeMirror {border-top: 1px solid #eee; border-bottom: 1px solid #eee; line-height: 1.3; height: 500px}
  23. .CodeMirror-linenumbers { padding: 0 8px; }
  24. </style>
  25. <div id=nav>
  26. <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>
  27. <ul>
  28. <li><a href="../index.html">Home</a>
  29. <li><a href="../doc/manual.html">Manual</a>
  30. <li><a href="https://github.com/codemirror/codemirror">Code</a>
  31. </ul>
  32. <ul>
  33. <li><a class=active href="#">Sublime bindings</a>
  34. </ul>
  35. </div>
  36. <article>
  37. <h2>Sublime Text bindings demo</h2>
  38. <p>The <code>sublime</code> keymap defines many Sublime Text-specific
  39. bindings for CodeMirror. See the code below for an overview.</p>
  40. <p>Enable the keymap by
  41. loading <a href="../keymap/sublime.js"><code>keymap/sublime.js</code></a>
  42. and setting
  43. the <a href="../doc/manual.html#option_keyMap"><code>keyMap</code></a>
  44. option to <code>"sublime"</code>.</p>
  45. <p>(A lot of the search functionality is still missing.)
  46. <script>
  47. var value = "// The bindings defined specifically in the Sublime Text mode\nvar bindings = {\n";
  48. var map = CodeMirror.keyMap.sublime;
  49. for (var key in map) {
  50. var val = map[key];
  51. if (key != "fallthrough" && val != "..." && (!/find/.test(val) || /findUnder/.test(val)))
  52. value += " \"" + key + "\": \"" + val + "\",\n";
  53. }
  54. value += "}\n\n// The implementation of joinLines\n";
  55. value += CodeMirror.commands.joinLines.toString().replace(/^function\s*\(/, "function joinLines(").replace(/\n /g, "\n") + "\n";
  56. var editor = CodeMirror(document.body.getElementsByTagName("article")[0], {
  57. value: value,
  58. lineNumbers: true,
  59. mode: "javascript",
  60. keyMap: "sublime",
  61. autoCloseBrackets: true,
  62. matchBrackets: true,
  63. showCursorWhenSelecting: true,
  64. theme: "monokai",
  65. tabSize: 2
  66. });
  67. </script>
  68. </article>