]> git.donarmstrong.com Git - dactyl.git/blob - common/locale/en-US/map.xml
640b321ea42acea58691bf0adf973c518c7d3b99
[dactyl.git] / common / locale / en-US / map.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <?xml-stylesheet type="text/xsl" href="dactyl://content/help.xsl"?>
3
4 <!DOCTYPE document SYSTEM "dactyl://content/dtd">
5
6 <document
7     name="map"
8     title="&dactyl.appName; Key Mappings"
9     xmlns="&xmlns.dactyl;"
10     xmlns:dactyl="&xmlns.dactyl;"
11     xmlns:html="&xmlns.html;">
12
13 <h1 tag="keyboard-shortcuts">Keyboard shortcuts and commands</h1>
14 <toc start="2"/>
15
16 <p>
17     &dactyl.appName; provides a number of commands to change the
18     behavior of key presses. This can mean anything from
19     automatically substituting one key for another or automatically
20     replacing one typed word for another, to launching a dialog or
21     running a command.
22 </p>
23
24 <h2 tag="key-mapping mapping map macro">Key mapping</h2>
25
26 <p>
27     Key mappings are the most basic means &dactyl.appName; provides
28     for altering the actions of key presses. Each key mapping is
29     associated with a mode, such as <link topic="insert-mode">insert</link>,
30     <link>normal</link>, or
31     <link topic="command-line-mode">command-line</link>, and only
32     has effect when that mode is active. Although each mode has a
33     full suite of internal mappings, they may be easily augmented,
34     altered, or removed with the <ex>:map</ex> command and its
35     variants. These commands, in essence, allow the user to quickly
36     substitute one sequence of key presses for another.
37     For instance,
38 </p>
39
40 <code><ex>:map <k name="F2" link="false"/></ex> <ex>:echo Date()<k name="CR"/></ex></code>
41
42 <p>
43     causes “<ex>:echo Date()<k name="CR"/></ex>” to be typed out
44     whenever <k name="F2" link="false"/> is pressed, thus echoing the full date
45     to the command line.
46 </p>
47
48 <p tag=":map-modes">
49     Standard key mapping commands are provided for the five most
50     common modes,
51 </p>
52
53 <dl dt="width: 8em;">
54     <dt>n</dt> <dd>Normal mode: When browsing normally</dd>
55     <dt>v</dt> <dd>Visual mode: When selecting text with the cursor keys</dd>
56     <dt>i</dt> <dd>Insert mode: When interacting with text fields on a website</dd>
57     <dt>t</dt> <dd>TextEdit mode: When editing text fields in Vim-like NORMAL mode</dd>
58     <dt>c</dt> <dd>Command-line mode: When typing into the &dactyl.appName; command line</dd>
59 </dl>
60
61 <p>
62     The ordinary <ex>:map</ex> and <ex>:noremap</ex> commands
63     add mappings for normal and visual mode. In order to map key
64     bindings in a different mode, any of the mapping commands may be
65     prefixed with one of the above letters. For instance,
66     <ex>:imap</ex> creates a new key mapping in insert mode, while
67     <ex>:cunmap</ex> removes a key mapping from command-line mode.
68     Other modes can be specified using the -modes option described below.
69 </p>
70
71 <warning>
72     It is important to note that mappings are <em>not</em>
73     automatically saved between sessions. In order to preserve them,
74     they must either be added to your <tt><t>&dactyl.name;rc</t></tt> or
75     saved via the <ex>:mk&dactyl.name;rc</ex> command.
76 </warning>
77
78 <h3 tag=":map-commands">Map commands</h3>
79
80 <item>
81     <tags>:map</tags>
82     <spec>:map <a>lhs</a> <a>rhs</a></spec>
83     <tags>:nm :nmap</tags>
84     <spec>:nm<oa>ap</oa> <a>lhs</a> <a>rhs</a></spec>
85     <tags>:vm :vmap</tags>
86     <spec>:vm<oa>ap</oa> <a>lhs</a> <a>rhs</a></spec>
87     <tags>:im :imap</tags>
88     <spec>:im<oa>ap</oa> <a>lhs</a> <a>rhs</a></spec>
89     <tags>:tm :tmap</tags>
90     <spec>:tm<oa>ap</oa> <a>lhs</a> <a>rhs</a></spec>
91     <tags>:cm :cmap</tags>
92     <spec>:cm<oa>ap</oa> <a>lhs</a> <a>rhs</a></spec>
93     <description>
94         <p>
95             Map the <t>key-sequence</t> <a>lhs</a> to <a>rhs</a> for
96             the applicable mode(s). The keys of <a>rhs</a> respect
97             user-defined mappings, so the following will result in
98             an infinite loop,
99         </p>
100         <code><ex>:map a b</ex>
101 <ex>:map b a</ex></code>
102         <p>
103             In order to avoid this shortcoming, the <ex>:noremap</ex> command
104             or the <em>-builtin</em> option may be used.
105         </p>
106     </description>
107 </item>
108
109 <h3 tag=":map-options">Map options</h3>
110 <p>
111     Any of the map commands may be given the following options:
112 </p>
113
114 <dl dt="width: 12em;">
115     <dt></dt> <dd></dd>
116
117     <dt>-arg</dt> <dd>Accept an argument after the requisite key press. Sets the <tt>arg</tt> parameter to the result. (short name <em>-a</em>)</dd>
118     <dt>-builtin</dt> <dd>Execute this mapping as if there were no user-defined mappings (short name <em>-b</em>)</dd>
119     <dt>-count</dt> <dd>Accept a count before the requisite key press. Sets the <tt>count</tt> parameter to the result. (short name <em>-c</em>)</dd>
120     <dt>-description</dt> <dd>A description of this mapping (short name <em>-d</em>)</dd>
121     <dt>-ex</dt> <dd>Execute <a>rhs</a> as an Ex command rather than keys (short name <em>-e</em>)</dd>
122     <dt>-group=<a>group</a></dt> <dd>Add this command to the given <t>group</t> (short name <em>-g</em>)</dd>
123     <dt>-javascript</dt> <dd>Execute <a>rhs</a> as JavaScript rather than keys (short names <em>-js</em>, <em>-j</em>)</dd>
124     <dt>-literal=<a>n</a></dt> <dd>Parse the <a>n</a>th argument without specially processing any quote or meta characters. (short name <em>-l</em>)</dd>
125     <dt>-modes</dt> <dd>Create this mapping in the given modes (short names <em>-mode</em>, <em>-m</em>)</dd>
126     <dt>-nopersist</dt> <dd>Do not save this mapping to an auto-generated rc file (short name <em>-n</em>)</dd>
127     <dt>-silent</dt> <dd>Do not echo any generated keys to the command line (short name <em>-s</em>, also <em>&lt;silent></em> for Vim compatibility)</dd>
128 </dl>
129
130 <item>
131     <tags>:no :noremap</tags>
132     <spec>:no<oa>remap</oa> <a>lhs</a> <a>rhs</a></spec>
133     <tags>:nn :nnoremap</tags>
134     <spec>:nn<oa>oremap</oa> <a>lhs</a> <a>rhs</a></spec>
135     <tags>:vn :vnoremap</tags>
136     <spec>:vn<oa>oremap</oa> <a>lhs</a> <a>rhs</a></spec>
137     <tags>:ino :inoremap</tags>
138     <spec>:ino<oa>remap</oa> <a>lhs</a> <a>rhs</a></spec>
139     <tags>:tno :tnoremap</tags>
140     <spec>:tno<oa>remap</oa> <a>lhs</a> <a>rhs</a></spec>
141     <tags>:cno :cnoremap</tags>
142     <spec>:cno<oa>remap</oa> <a>lhs</a> <a>rhs</a></spec>
143     <description>
144         <p>
145             Map the <t>key-sequence</t> <a>lhs</a> to <a>rhs</a> for
146             the applicable mode(s). The keys in <a>rhs</a> do not
147             respect user-defined key mappings, so the following
148             effectively reverses the default meanings of the keys
149             <k>d</k> and <k>D</k>
150         </p>
151         <code><ex>:noremap d D</ex>
152 <ex>:noremap D d</ex></code>
153     </description>
154 </item>
155
156 <item>
157     <spec>:unmap <a>lhs</a></spec>
158     <tags>:unm :unmap</tags>
159     <spec>:unmap!</spec>
160     <spec>:nun<oa>map</oa> <a>lhs</a></spec>
161     <tags>:nun :nunmap</tags>
162     <spec>:nun<oa>map</oa>!</spec>
163     <spec>:vun<oa>map</oa> <a>lhs</a></spec>
164     <tags>:vun :vunmap</tags>
165     <spec>:vun<oa>map</oa>!</spec>
166     <spec>:iu<oa>nmap</oa> <a>lhs</a></spec>
167     <tags>:iu :iunmap</tags>
168     <spec>:iu<oa>nmap</oa>!</spec>
169     <spec>:tu<oa>nmap</oa> <a>lhs</a></spec>
170     <tags>:tu :tunmap</tags>
171     <spec>:tu<oa>nmap</oa>!</spec>
172     <spec>:cu<oa>nmap</oa> <a>lhs</a></spec>
173     <tags>:cu :cunmap</tags>
174     <spec>:cu<oa>nmap</oa>!</spec>
175     <description>
176         <p>Remove the mapping of <a>lhs</a> (or all mappings if <oa>!</oa> is
177             given) for the applicable mode(s).</p>
178     </description>
179 </item>
180
181 <item>
182     <spec>:map</spec>
183     <spec>:nm<oa>ap</oa></spec>
184     <spec>:vm<oa>ap</oa></spec>
185     <spec>:im<oa>ap</oa></spec>
186     <spec>:tm<oa>ap</oa></spec>
187     <spec>:cm<oa>ap</oa></spec>
188     <description>
189         <p>
190             List all mappings for the applicable mode(s). Mappings are
191             partitioned into <t>groups</t>.
192         </p>
193     </description>
194 </item>
195
196 <item>
197     <tags>:map_l</tags>
198     <spec>:map <a>lhs</a></spec>
199     <tags>:nmap_l</tags>
200     <spec>:nm<oa>ap</oa> <a>lhs</a></spec>
201     <tags>:vmap_l</tags>
202     <spec>:vm<oa>ap</oa> <a>lhs</a></spec>
203     <tags>:imap_l</tags>
204     <spec>:im<oa>ap</oa> <a>lhs</a></spec>
205     <tags>:tmap_l</tags>
206     <spec>:tm<oa>ap</oa> <a>lhs</a></spec>
207     <tags>:cmap_l</tags>
208     <spec>:cm<oa>ap</oa> <a>lhs</a></spec>
209     <description>
210         <p>List all mappings starting with <a>lhs</a> for the applicable mode(s).</p>
211     </description>
212 </item>
213
214 <h3 tag=":map-timeout map-timeout">Mapping timeout</h3>
215 <p>
216     When &dactyl.appName; receives a key event that has a separate binding and
217     at the same time is part of a key chain, values of the <o>timeout</o> and
218     <o>timeoutlen</o> options are used to decide what to do. See the
219     documentation of those options for more information.
220 </p>
221
222 <h3 tag=":map-arguments">Special arguments</h3>
223
224 <p>
225     Below is an overview of which modes each map command applies to:
226 </p>
227
228 <!-- TODO: table format -->
229
230 <code>
231 :map   :noremap   :unmap   :mapclear  – both Normal and Visual modes
232 :nmap  :nnoremap  :nunmap  :nmapclear – Normal mode
233 :vmap  :vnoremap  :vunmap  :vmapclear – Visual mode
234 :imap  :inoremap  :iunmap  :imapclear – Insert mode
235 :tmap  :tnoremap  :tunmap  :tmapclear – Text Edit mode
236 :cmap  :cnoremap  :cunmap  :cmapclear – Command-line mode
237 </code>
238
239 <h3 tag="key-notation key-sequence">Key sequences</h3>
240
241 <p>
242     Most keys in key sequences are represented simply by the
243     character that you see on the screen when you type them.
244     However, as a number of these characters have special meanings,
245     and a number of keys have no visual representation, a special
246     notation is required.
247 </p>
248
249 <ul>
250     <li>
251         The first argument to the <ex>:map</ex> commands must be
252         <link topic="quoting">quoted</link> if it contains spaces,
253         quotation marks or back-slashes. A space may additionally be
254         typed as <k name="Space"/>.
255     </li>
256     <li key="&lt;lt>">
257         As special key names start with the <em>&lt;</em> character,
258         a literal &lt; must be typed as <k name="lt" link="false"/>.
259     </li>
260     <li>
261         <k name="Left"/>, <k name="Right"/>, <k name="Up"/>,
262         and <k name="Down"/> represent the standard arrow keys.
263     </li>
264     <li>
265         <k name="CapsLock" link="false"/>, <k name="NumLock" link="false"/>, <k name="Insert"/>
266         <k name="Del" link="false"/>, <k name="Tab"/>, <k name="PageUp"/>,
267         <k name="PageDown"/>, and <k name="Esc"/> work as
268         expected.
269    </li>
270     <li>
271         <k name="Return" link="false"/> or <k name="CR"/> represent the carriage
272         return key.
273     </li>
274     <li><k name="BS" link="false"/> represents the backspace key.</li>
275     <li><k name="F1"/> through <k name="F12" link="false"/> work as expected.</li>
276     <li>
277         <k name="K0" link="false"/> through <k name="K9" link="false"/> represent keys on the
278         numeric keypad.
279     </li>
280     <li>
281         <k name="Uxxxx" link="false"/>, where <em>xxxx</em> is any 4 hexadecimal
282         digits, represents the character at that Unicode codepoint.
283         For instance, <k name="U263a" link="false"/> represents ☺.
284     </li>
285 </ul>
286
287 <p>
288     In order to represent key presses using the Control, Alt, Meta,
289     or Shift keys, the following prefixes may be used,
290 </p>
291
292 <ol>
293     <li><k name="C-␣" link="false"/>: The control or ctrl key.</li>
294     <li><k name="A-␣" link="false"/>: The alt key.</li>
295     <li><k name="M-␣" link="false"/>: The meta key, windows key, or command key.</li>
296     <li><k name="S-␣" link="false"/>: The shift key.</li>
297 </ol>
298
299 <p>
300     These prefixes can be combined however you see fit.
301 </p>
302
303 <note>
304     Within angle brackets all alphabetic characters are read as lowercase.
305     Uppercase characters can only be specified with the <em>S-</em> modifier.
306 </note>
307
308 <p>
309     The following key sequences are interpreted as described:
310 </p>
311
312 <dl dt="width: 10em;">
313     <dt><k link="false">xc</k></dt>
314     <dd>Type the ‘X’ key followed by the ‘C’ key.</dd>
315
316     <dt><k name="C-x" link="false">c</k></dt>
317     <dd>
318         Type the ‘X’ key while holding the ‘Control’ key, followed
319         by the ‘C’ key.
320     </dd>
321
322     <dt><k name="C-2" link="false"/></dt>
323     <dd>Type the ‘2’ while holding the ‘Control’ key.</dd>
324
325     <dt><k name="C-@" link="false"/></dt>
326     <dd>Type the ‘@’ key while holding the ‘Control’ key.</dd>
327
328     <dt><k name="S-Space" link="false"/></dt>
329     <dd>Press the space bar while holding the ‘Shift’ key.</dd>
330
331     <dt><k name="C-A-j" link="false"/></dt>
332     <dd>Type the ‘J’ key while while holding both the ‘Control’ and ‘Alt’ keys.</dd>
333
334     <dt><k name="C-A-J" link="false"/></dt>
335     <dd>Exactly the same as above.</dd>
336
337     <dt><k name="C-A-S-j" link="false"/></dt>
338     <dd>Type the ‘J’ key while while holding both the ‘Control’, ‘Alt’, and ‘Shift’ keys.</dd>
339 </dl>
340
341 <h3 tag=":map-special-chars">Special characters</h3>
342
343 <item>
344     <tags><![CDATA[<Nop>]]></tags>
345     <strut/>
346     <spec><![CDATA[<Nop>]]></spec>
347     <description>
348         <p>
349             Do nothing. This pseudo-key is useful for disabling a
350             specific builtin mapping. For example,
351             <ex>:map <k name="C-n"/> <k name="Nop"/></ex> will prevent <k name="C-n"/>
352             from doing anything.
353         </p>
354     </description>
355 </item>
356
357 <item>
358     <tags><![CDATA[<Pass>]]></tags>
359     <spec><![CDATA[<Pass>]]></spec>
360     <description short="true">
361         <p>
362             Pass the events consumed by the last executed mapping through to &dactyl.host;.
363         </p>
364     </description>
365 </item>
366
367 <item>
368     <tags><![CDATA[<CR> map_return]]></tags>
369     <strut/>
370     <spec><![CDATA[<CR>]]></spec>
371     <description>
372         <p>
373             Expand to a line terminator in a key mapping. An Ex command in the <a>rhs</a> of a
374             mapping requires a line terminator after it so that it is executed when the
375             mapping is expanded. <k name="CR"/> should be used for this purpose.
376         </p>
377     </description>
378 </item>
379
380 <item>
381     <tags><![CDATA[<Leader> \]]></tags>
382     <strut/>
383     <spec><![CDATA[<Leader>]]></spec>
384     <description>
385         <p>
386             A pseudo-key which expands to the value of the <o>mapleader</o>
387             option. For example, by default,
388         </p>
389         <code><ex>:map <k name="Leader"/>h</ex> <ex>:echo <str>Hello</str><k name="CR"/></ex></code>
390         <p>works like</p>
391         <code><ex>:map \h</ex> <ex>:echo <str>Hello</str><k name="CR"/></ex></code>
392         <p>but after</p>
393         <set opt="mapleader"><str>,</str></set>
394         <p>it works like</p>
395         <code><ex>:map ,h</ex> <ex>:echo <str>Hello</str><k name="CR"/></ex></code>
396     </description>
397 </item>
398
399 <h2 tag="abbreviations">Abbreviations</h2>
400
401 <p>
402     In addition to basic mappings, &dactyl.appName; can also
403     automatically replace whole words after they've been typed.
404     These shortcuts are known as abbreviations, and are most often
405     useful for correcting spelling of commonly mistyped words, as
406     well as shortening the typing of oft-typed but long words or
407     phrases. There are three basic types of abbreviations, defined
408     by the types of characters they contain,
409 </p>
410
411 <ul>
412     <li>‘full-id’ abbreviations consist entirely of keyword characters (e.g., ‘teh’, ‘msoft’).</li>
413     <li>‘end-id’ abbreviations end in keyword character but otherwise contains all non-keyword characters (e.g., ‘'i’).</li>
414     <li>‘non-id’ abbreviations end in a non-keyword character but otherwise contains any non-whitespace character (e.g., ‘def'’).</li>
415     <li>Strings which fit none of the above patterns can not be defined as abbreviations (e.g., ‘a'b’ and ‘a b’).</li>
416 </ul>
417
418 <p>
419     For the purposes of abbreviations, keyword characters include
420     all non-whitespace characters except for single or double
421     quotation marks. Abbreviations are expanded as soon as any
422     non-keyword character, or the key <k name="C-]" mode="c"/>, is typed.
423 </p>
424
425 <item>
426     <tags>:ab :abbreviate</tags>
427     <spec>:ab<oa>breviate</oa> <oa>-group=<a>group</a></oa> <a>lhs</a> <a>rhs</a></spec>
428     <spec>:ab<oa>breviate</oa> <oa>-group=<a>group</a></oa> <a>lhs</a></spec>
429     <spec>:ab<oa>breviate</oa> <oa>-group=<a>group</a></oa></spec>
430     <description>
431         <p>
432             Abbreviate <a>lhs</a> to <a>rhs</a>. If only <a>lhs</a>
433             is given, list all abbreviations that start with
434             <a>lhs</a>. If no arguments are given, list all
435             abbreviations.
436         </p>
437
438         <p>
439             If the <em>-javascript</em> (short names <em>-js</em>,
440             <em>-j</em>) option is given, <a>lhs</a> is expanded to
441             the value <em>return</em>ed by the JavaScript code
442             <a>rhs</a>. The code is evaluated with the variable
443             <em>editor</em> set to the editable element that the
444             abbreviation is currently being expanded in. The code
445             should <em>not</em> make any changes to the contents of
446             the editor.
447         </p>
448
449         <p>
450             If <a>group</a> is specified then abbreviations are created or
451             listed for the given <t>group</t>.
452         </p>
453     </description>
454 </item>
455
456 <item>
457     <tags>:ca :cabbreviate</tags>
458     <spec>:ca<oa>bbreviate</oa> <a>lhs</a> <a>rhs</a></spec>
459     <spec>:ca<oa>bbreviate</oa> <a>lhs</a></spec>
460     <spec>:ca<oa>bbreviate</oa></spec>
461     <description>
462         <p>
463             Abbreviate a key sequence for Command-line mode. Same as
464             <ex>:ab<oa>breviate</oa></ex>, but for
465             <t>command-line</t> mode only.
466         </p>
467     </description>
468 </item>
469
470 <item>
471     <tags>:ia :iabbreviate</tags>
472     <spec>:ia<oa>bbreviate</oa> <a>lhs</a> <a>rhs</a></spec>
473     <spec>:ia<oa>bbreviate</oa> <a>lhs</a></spec>
474     <spec>:ia<oa>bbreviate</oa></spec>
475     <description>
476         <p>
477             Abbreviate a key sequence for Insert mode. Same as
478             <ex>:ab<oa>breviate</oa></ex>, but for insert mode only.
479         </p>
480     </description>
481 </item>
482
483 <item>
484     <tags>:una :unabbreviate</tags>
485     <spec>:una<oa>bbreviate</oa> <a>lhs</a></spec>
486     <spec>:una<oa>bbreviate</oa>!</spec>
487     <description>
488         <p>Remove an abbreviation. With <oa>!</oa>, remove all abbreviations.</p>
489     </description>
490 </item>
491
492 <item>
493     <tags>:cuna :cunabbreviate</tags>
494     <spec>:cuna<oa>bbreviate</oa> <a>lhs</a></spec>
495     <spec>:cuna<oa>bbreviate</oa>!</spec>
496     <description>
497         <p>
498             Remove abbreviation(s) for Command-line mode. Same as
499             <ex>:una<oa>bbreviate</oa></ex>, but for
500             <t>command-line</t> mode only.
501         </p>
502     </description>
503 </item>
504
505 <item>
506     <tags>:iuna :iunabbreviate</tags>
507     <spec>:iuna<oa>bbreviate</oa> <a>lhs</a></spec>
508     <spec>:iuna<oa>bbreviate</oa>!</spec>
509     <description>
510         <p>
511             Remove abbreviation(s) for Insert mode. Same as
512             <ex>:una<oa>bbreviate</oa></ex> but for Insert mode
513             only.
514         </p>
515     </description>
516 </item>
517
518 <h2 tag="user-commands">User-defined commands</h2>
519
520 <p>
521     Defining new commands is perhaps the most straightforward way of
522     repeating commonly used actions. User-defined commands may be
523     entered from the command line or scripts exactly like standard
524     commands, and may similarly accept arguments, options, counts,
525     and <oa>!</oa>s, as well as provide command-line completion.
526     These commands may be defined as either ordinary,
527     macro-interpolated Ex commands, or otherwise as plain
528     JavaScript statements.
529 </p>
530
531 <item>
532     <tags>:com :command</tags>
533     <spec>:com<oa>mand</oa></spec>
534     <description short="true">
535         <p>List all user-defined commands.</p>
536     </description>
537 </item>
538
539 <item>
540     <spec>:com<oa>mand</oa> <oa>cmd</oa></spec>
541     <description>
542         <p>
543             List all user-defined commands that start with <oa>cmd</oa>. Commands
544             are partitioned into <t>groups</t>.
545         </p>
546     </description>
547 </item>
548
549 <item>
550     <spec>:com<oa>mand</oa><oa>!</oa> <oa><a>options</a>…</oa> <a>cmd</a> <a>rep</a></spec>
551     <description>
552         <p>
553             Define a new user command. The name of the command is
554             <a>cmd</a> and its replacement text is <a>rep</a>. If a
555             command with this name already exists, an error is
556             reported unless <oa>!</oa> is specified, in which case
557             the command is redefined. Unlike Vim, the command may
558             start with a lowercase letter. <a>cmd</a> may also be multiple
559             alternative command names separated by commas.
560         </p>
561
562         <p>
563             The new command is usually defined by a string to be
564             executed as an Ex command. In this case, before
565             execution, strings of the form
566             <hl key="HelpKey">&lt;<a>var</a>></hl> are interpolated
567             as described below, in order to insert arguments,
568             options, and the like. If the <em>-javascript</em> (short
569             name <em>-js</em>) flag is present, the command is
570             executed as JavaScript, and the arguments are present as
571             variables in its scope instead, and no interpolation is
572             performed.
573         </p>
574
575         <p>
576             The command's behavior can be altered by providing
577             options when the command is defined.
578         </p>
579
580         <h3 tag=":command-group">Grouping</h3>
581
582         <p>
583             The <em>-group</em> flag (short name: <em>-g</em>) can be used to
584             assign this command to a specific <t>group</t>.
585         </p>
586
587         <h3 tag="E175 E176 :command-nargs">Argument handling</h3>
588
589         <p>
590             By default, user commands accept no arguments. This can be changed by specifying
591             the <tt>-nargs</tt> option.
592         </p>
593
594         <p>The valid values are:</p>
595
596         <dl>
597             <dt>-nargs=0</dt><dd>No arguments are allowed (default)</dd>
598             <dt>-nargs=1</dt><dd>One argument is allowed</dd>
599             <dt>-nargs=*</dt><dd>Zero or more arguments are allowed</dd>
600             <dt>-nargs=?</dt><dd>Zero or one argument is allowed</dd>
601             <dt>-nargs=+</dt><dd>One or more arguments are allowed</dd>
602         </dl>
603
604         <h3 tag="E180 E181 :command-complete">Argument completion</h3>
605
606         <p>
607             Completion for arguments to user-defined commands is not available by default.
608             Completion can be enabled by specifying one of the following arguments to the
609             -complete option when defining the command.
610         </p>
611
612         <dl tag=":command-complete-arg-list"/>
613
614         <h3 tag="E467 E468 :command-completion-custom">Custom completion</h3>
615
616         <p>
617             Custom completion can be provided by specifying the
618             <str>custom,<a>thing</a></str> argument to <tt>-complete</tt>. If
619             <a>thing</a> evaluates to a function (i.e., it is a variable holding
620             a function value, or a string containing the definition itself), it
621             is called with two arguments: a completion context, and an object
622             describing the command's arguments. It should set the context's
623             <tt>completions</tt> property to the list of completion results.
624             Other influential properties include <tt>title</tt>, <tt>sort</tt>,
625             <tt>anchored</tt>, and <tt>filters</tt>, which are documented in the
626             <link topic="resource://dactyl/completion.jsm"
627                 line="17" dactyl:command="buffer.viewSource">source code</link>.
628         </p>
629
630         <p>
631             <em>completions</em> is a two-dimensional array of the form:
632             <tt>[[arg1, description1], [arg2, description2], …]</tt>
633         </p>
634
635         <p>
636             Otherwise <a>thing</a> should evaluate to an array of the same form
637             as the <tt>completions</tt> property of the context object.
638         </p>
639
640         <p>
641             Example:
642             <code><ex>:command foo -nargs=? -complete custom,<str delim="'">
643     \ function (context) context.completions = [["arg1", "description1"], ["arg2", "description2"]]</str>
644     \ <ex>:echo</ex> <str>Useless </str> + <em>&lt;q-args></em></ex>
645
646 <ex>:command foo -nargs=?
647     \ -complete custom,<str delim="'">[["arg1", "description1"], ["arg2, "description2"]]</str>
648     \ <ex>:echo</ex> <str>Same as above but simpler </str> + <em>&lt;q-args></em></ex></code>
649         </p>
650
651         <h3 tag="E177 E178 :command-count">Count handling</h3>
652
653         <p>
654             By default, user commands do not accept a count. Use the -count option if
655             you'd like to have a count passed to your user command. This will then be
656             available for expansion as &lt;count> in the replacement.
657         </p>
658
659         <h3 tag=":command-bang">Special cases</h3>
660
661         <p>
662             By default, a user command does not have a special version, i.e. a version
663             executed with the ! modifier. Providing the -bang option will enable this
664             and &lt;bang> will be available in the replacement.
665         </p>
666
667         <h3 tag=":command-description">Command description</h3>
668
669         <p>
670             The command's description text can be set with -description. Otherwise it will
671             default to "User-defined command".
672         </p>
673
674         <h3 tag=":command-replacement-text">Replacement text</h3>
675
676         <p>
677             The replacement text <a>rep</a> is scanned for <t>macro-string</t>s and these are
678             replaced with values from the user-entered command line. The resulting string
679             is then executed as an Ex command.
680         </p>
681
682         <p>
683             In addition to the standard parameters listed in
684             <t>macro-string</t>, the following parameters are available:
685         </p>
686
687         <dl>
688             <dt>&lt;args></dt> <dd>The command arguments exactly as supplied</dd>
689             <dt>&lt;count></dt><dd>Any supplied count, e.g. 5</dd>
690             <dt>&lt;bang></dt> <dd>! if the command was executed with the ! modifier</dd>
691         </dl>
692     </description>
693 </item>
694
695 <item>
696     <tags>:delc :delcommand</tags>
697     <spec>:delc<oa>ommand</oa> <a>cmd</a></spec>
698     <spec>:delc<oa>ommand</oa>!</spec>
699     <description>
700         <p>Delete the user-defined command <a>cmd</a>. With <oa>!</oa>, delete
701             all user commands.</p>
702     </description>
703 </item>
704
705 <h2 tag="command-examples">Examples</h2>
706
707 <p>Add a :Google command to search via google:</p>
708 <code><ex>:command -nargs=* Google open google &lt;args></ex></code>
709
710 <!-- TODO: add decent examples -->
711
712 </document>
713
714 <!-- vim:se sts=4 sw=4 et: -->