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">
15 <style type="text/css">
16 .CodeMirror {border-top: 1px solid #eee; border-bottom: 1px solid #eee;}
20 <h1>CodeMirror: Vim bindings demo</h1>
22 <form><textarea id="code" name="code">
24 /* getchar: simple buffered version */
27 static char buf[BUFSIZ];
28 static char *bufp = buf;
30 if (n == 0) { /* buffer is empty */
31 n = read(0, buf, sizeof buf);
34 return (--n >= 0) ? (unsigned char) *bufp++ : EOF;
38 <form><textarea id="code2" name="code2">
39 I am another file! You can yank from my neighbor and paste here.
42 <p>The vim keybindings are enabled by
43 including <a href="../keymap/vim.js">keymap/vim.js</a> and setting
44 the <code>keyMap</code> option to <code>"vim"</code>. Because
45 CodeMirror's internal API is quite different from Vim, they are only
46 a loose approximation of actual vim bindings, though.</p>
49 CodeMirror.commands.save = function(){ alert("Saving"); };
50 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
54 showCursorWhenSelecting: true
56 var editor2 = CodeMirror.fromTextArea(document.getElementById("code2"), {
60 showCursorWhenSelecting: true