1 <?xml version="1.0" encoding="UTF-8"?>
2 <?xml-stylesheet type="text/xsl" href="dactyl://content/help.xsl"?>
4 <!DOCTYPE document SYSTEM "dactyl://content/dtd">
8 title="&dactyl.appName; Autocommands"
10 xmlns:html="&xmlns.html;">
12 <h1 tag="autocommands">Automatic commands</h1>
16 Autocommands are a way to automatically execute code when
17 certain events happen.
21 <tags>:au :autocmd</tags>
22 <spec>:au<oa>tocmd</oa><oa>!</oa> <oa>events</oa> <oa>filter</oa> <oa>cmd</oa></spec>
24 <p>Execute commands automatically on events.</p>
27 When <oa>cmd</oa> is not given, list all commands
28 defined for the given <oa>events</oa> and <oa>filter</oa>.
29 When <oa>!</oa> is given, delete the matching commands
30 rather than listing them.
34 When <oa>cmd</oa> is given, add it to the list of commands to be
35 executed when <oa>events</oa> occur for pages matching the
36 comma-separated list of <t>site-filters</t>, <oa>filter</oa>. If the
37 <em>-javascript</em> (short name <em>-js</em>) option is given,
38 <oa>cmd</oa> is interpreted as JavaScript code. Otherwise, it is
39 interpreted as an Ex command.
43 If the <em>-group</em>=<a>group</a> flag is given, add this
44 autocommand to the named <t>group</t>. Any filters for <a>group</a>
45 apply in addition to <oa>filter</oa>. When listing commands this
46 limits the output to the specified group.
49 <p>Available <oa>events</oa>:</p>
51 <dl tag="autocommand-list"/>
54 For Ex <oa>cmd</oa>s, the following keywords are
55 replaced with the appropriate value before the commands
56 are executed. For JavaScript commands, they may be
57 accessed as ordinary variables, sans angle brackets.
60 <dl tag="autocommand-args"/>
68 <tags>:doautoa :doautoall</tags>
69 <spec>:doautoa<oa>ll</oa> <a>event</a> <oa>url</oa></spec>
72 Apply all <a>event</a> autocommands matching the
73 specified <oa>url</oa> to all buffers. If no
74 <oa>url</oa> is specified use the current URL.
80 <tags>:do :doautocmd</tags>
81 <spec>:do<oa>autocmd</oa> <a>event</a> <oa>url</oa></spec>
84 Apply all autocommands matching the specified
85 <oa>url</oa> to the current buffer. If no <oa>url</oa>
86 is specified use the current URL.
90 <h2 tag="autocmd-examples">Examples</h2>
92 <p>Enable <em>Pass Through</em> mode on all Google sites:</p>
94 <code><ex>:autocmd LocationChange</ex> <str delim="">google.com</str> <ex>:normal!</ex> <k name="C-z"/></code>
96 <p>Enable <em>Pass Through</em> mode on <em>some</em> Google sites:</p>
98 <code><ex>:autocmd LocationChange</ex> <str delim="">www.google.com</str>,<str delim="">mail.google.com</str> <ex>:normal!</ex> <k name="C-z"/></code>
102 <code><ex>:autocmd LocationChange</ex> <str delim="'">^https?://(www|mail)\.google\.com/</str> <ex>:normal!</ex> <k name="C-z"/></code>
104 <p>Set the filetype to mail when editing email at Gmail:</p>
106 <code><ex>:autocmd LocationChange</ex> !<str delim="">mail.google.com</str>,<str delim="">*</str> <se opt="editor" op="&"/>
107 <ex>:autocmd LocationChange</ex> <str delim="'">mail.google.com</str> <se opt="editor"><str>gvim -f -c 'set ft=mail' +<line></str></se></code>
111 <!-- vim:se sts=4 sw=4 et: -->