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 autocmd
44 to the named <t>group</t>. Any filters for <a>group</a> apply in
45 addition to <oa>filter</oa>.
48 <p>Available <oa>events</oa>:</p>
50 <dl tag="autocommand-list"/>
53 For Ex <oa>cmd</oa>s, the following keywords are
54 replaced with the appropriate value before the commands
55 are executed. For JavaScript commands, they may be
56 accessed as ordinary variables, sans angle brackets.
59 <dl tag="autocommand-args"/>
67 <tags>:doautoa :doautoall</tags>
68 <spec>:doautoa<oa>ll</oa> <a>event</a> <oa>url</oa></spec>
71 Apply all <a>event</a> autocommands matching the
72 specified <oa>url</oa> to all buffers. If no
73 <oa>url</oa> is specified use the current URL.
79 <tags>:do :doautocmd</tags>
80 <spec>:do<oa>autocmd</oa> <a>event</a> <oa>url</oa></spec>
83 Apply all autocommands matching the specified
84 <oa>url</oa> to the current buffer. If no <oa>url</oa>
85 is specified use the current URL.
89 <h2 tag="autocmd-examples">Examples</h2>
91 <p>Enable <em>passthrough</em> mode on all Google sites:</p>
93 <code><ex>:autocmd LocationChange</ex> <str delim="">google.com</str> <ex>:normal!</ex> <k name="C-z"/></code>
95 <p>Enable <em>passthrough</em> mode on <em>some</em> Google sites:</p>
97 <code><ex>:autocmd LocationChange</ex> <str delim="'">^https?://(www|mail)\.google\.com/</str> <ex>:normal!</ex> <k name="C-z"/></code>
101 <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>
103 <p>Set the filetype to mail when editing email at Gmail:</p>
105 <code><ex>:autocmd LocationChange</ex> !<str delim="">mail.google.com</str>,<str delim="">*</str> <se opt="editor" op="&"/>
106 <ex>:autocmd LocationChange</ex> <str delim="'">mail.google.com</str> <se opt="editor"><str>gvim -f -c 'set ft=mail' +<line></str></se></code>
110 <!-- vim:se sts=4 sw=4 et: -->