Debian Codegraph @

src/editor/libs/codemirror/demo/vim.html

raw
1 <!doctype html>
2
3 <title>CodeMirror: Vim bindings demo</title>
4 <meta charset="utf-8"/>
5 <link rel=stylesheet href="../doc/docs.css">
6
7 <link rel="stylesheet" href="../lib/codemirror.css">
8 <link rel="stylesheet" href="../addon/dialog/dialog.css">
9 <link rel="stylesheet" href="../theme/midnight.css">
10 <link rel="stylesheet" href="../theme/solarized.css">
11 <script src="../lib/codemirror.js"></script>
12 <script src="../addon/dialog/dialog.js"></script>
13 <script src="../addon/search/searchcursor.js"></script>
14 <script src="../mode/clike/clike.js"></script>
15 <script src="../addon/edit/matchbrackets.js"></script>
16 <script src="../keymap/vim.js"></script>
17 <style>
18 .CodeMirror {border-top: 1px solid #eee; border-bottom: 1px solid #eee;}
19 </style>
20 <div id=nav>
21 <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>
22
23 <ul>
24 <li><a href="../index.html">Home</a>
25 <li><a href="../doc/manual.html">Manual</a>
26 <li><a href="https://github.com/codemirror/codemirror">Code</a>
27 </ul>
28 <ul>
29 <li><a class=active href="#">Vim bindings</a>
30 </ul>
31 </div>
32
33 <article>
34 <h2>Vim bindings demo</h2>
35
36 <p><strong style="color: #c33; text-decoration: none">Note:</strong> The CodeMirror vim bindings do not have an
37 active maintainer. That means that if you report bugs in it, they are
38 likely to go unanswered. It also means that if you want to help, you
39 are very welcome to look
40 at <a href="https://github.com/codemirror/codemirror/issues?q=is%3Aissue+is%3Aopen+label%3Avim">the
41 open issues</a> and see which ones you can solve.</p>
42
43 <form><textarea id="code" name="code">
44 #include "syscalls.h"
45 /* getchar: simple buffered version */
46 int getchar(void)
47 {
48 static char buf[BUFSIZ];
49 static char *bufp = buf;
50 static int n = 0;
51 if (n == 0) { /* buffer is empty */
52 n = read(0, buf, sizeof buf);
53 bufp = buf;
54 }
55 return (--n >= 0) ? (unsigned char) *bufp++ : EOF;
56 }
57 </textarea></form>
58 <div style="font-size: 13px; width: 300px; height: 30px;">Key buffer: <span id="command-display"></span></div>
59
60 <p>The vim keybindings are enabled by including <code><a
61 href="../keymap/vim.js">keymap/vim.js</a></code> and setting the
62 <code>keyMap</code> option to <code>vim</code>.</p>
63
64 <p><strong>Features</strong></p>
65
66 <ul>
67 <li>All common motions and operators, including text objects</li>
68 <li>Operator motion orthogonality</li>
69 <li>Visual mode - characterwise, linewise, blockwise</li>
70 <li>Full macro support (q, @)</li>
71 <li>Incremental highlighted search (/, ?, #, *, g#, g*)</li>
72 <li>Search/replace with confirm (:substitute, :%s)</li>
73 <li>Search history</li>
74 <li>Jump lists (Ctrl-o, Ctrl-i)</li>
75 <li>Key/command mapping with API (:map, :nmap, :vmap)</li>
76 <li>Sort (:sort)</li>
77 <li>Marks (`, ')</li>
78 <li>:global</li>
79 <li>Insert mode behaves identical to base CodeMirror</li>
80 <li>Cross-buffer yank/paste</li>
81 </ul>
82
83 <p>For the full list of key mappings and Ex commands, refer to the
84 <code>defaultKeymap</code> and <code>defaultExCommandMap</code> at the
85 top of <code><a href="../keymap/vim.js">keymap/vim.js</a></code>.
86
87 <p>Note that while the vim mode tries to emulate the most useful
88 features of vim as faithfully as possible, it does not strive to
89 become a complete vim implementation</p>
90
91 <script>
92 CodeMirror.commands.save = function(){ alert("Saving"); };
93 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
94 lineNumbers: true,
95 mode: "text/x-csrc",
96 keyMap: "vim",
97 matchBrackets: true,
98 showCursorWhenSelecting: true,
99 inputStyle: "contenteditable"
100 });
101 var commandDisplay = document.getElementById('command-display');
102 var keys = '';
103 CodeMirror.on(editor, 'vim-keypress', function(key) {
104 keys = keys + key;
105 commandDisplay.innerHTML = keys;
106 });
107 CodeMirror.on(editor, 'vim-command-done', function(e) {
108 keys = '';
109 commandDisplay.innerHTML = keys;
110 });
111 </script>
112
113 </article>