1
0

vim.html 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>CodeMirror: Vim bindings demo</title>
  6. <link rel="stylesheet" href="../lib/codemirror.css">
  7. <script src="../lib/codemirror.js"></script>
  8. <script src="../addon/dialog/dialog.js"></script>
  9. <script src="../addon/search/searchcursor.js"></script>
  10. <script src="../mode/clike/clike.js"></script>
  11. <script src="../keymap/vim.js"></script>
  12. <link rel="stylesheet" href="../doc/docs.css">
  13. <link rel="stylesheet" href="../addon/dialog/dialog.css">
  14. <style type="text/css">
  15. .CodeMirror {border-top: 1px solid #eee; border-bottom: 1px solid #eee;}
  16. </style>
  17. </head>
  18. <body>
  19. <h1>CodeMirror: Vim bindings demo</h1>
  20. <form><textarea id="code" name="code">
  21. #include "syscalls.h"
  22. /* getchar: simple buffered version */
  23. int getchar(void)
  24. {
  25. static char buf[BUFSIZ];
  26. static char *bufp = buf;
  27. static int n = 0;
  28. if (n == 0) { /* buffer is empty */
  29. n = read(0, buf, sizeof buf);
  30. bufp = buf;
  31. }
  32. return (--n >= 0) ? (unsigned char) *bufp++ : EOF;
  33. }
  34. </textarea></form>
  35. <form><textarea id="code2" name="code2">
  36. I am another file! You can yank from my neighbor and paste here.
  37. </textarea></form>
  38. <p>The vim keybindings are enabled by
  39. including <a href="../keymap/vim.js">keymap/vim.js</a> and setting
  40. the <code>keyMap</code> option to <code>"vim"</code>. Because
  41. CodeMirror's internal API is quite different from Vim, they are only
  42. a loose approximation of actual vim bindings, though.</p>
  43. <script>
  44. CodeMirror.commands.save = function(){ alert("Saving"); };
  45. var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
  46. lineNumbers: true,
  47. mode: "text/x-csrc",
  48. keyMap: "vim",
  49. showCursorWhenSelecting: true
  50. });
  51. var editor2 = CodeMirror.fromTextArea(document.getElementById("code2"), {
  52. lineNumbers: true,
  53. mode: "text/x-csrc",
  54. keyMap: "vim",
  55. showCursorWhenSelecting: true
  56. });
  57. </script>
  58. </body>
  59. </html>