Autocommands are a way to automatically execute code when
certain events happen.
:au[tocmd]
Execute commands automatically on events.
:au[tocmd] {event} {pat} {cmd}
If the -javascript (short name -js)
option is specified, {cmd} is executed as JavaScript
code, with any supplied arguments available as
variables.
Add {cmd} to the list of commands Vimperator will execute on {event} for a URL matching {pat}:
- :autocmd[!] {events} {pat}: list/remove autocommands filtered by {events} and {pat}
- :autocmd[!] {events}: list/remove autocommands matching {events}
- :autocmd[!] {pat}: list/remove autocommands matching {pat}
- :autocmd[!]: list/remove all autocommands
Available {events}:
- BookmarkAdd
- Triggered after a page is bookmarked
|
- ColorScheme
- Triggered after a color scheme has been loaded
|
- DOMLoad
- Triggered when a page's DOM content has fully loaded
|
- DownloadPost
- Triggered when a download has completed
|
- Fullscreen
- Triggered when the browser's fullscreen state changes
|
- LocationChange
- Triggered when changing tabs or when navigating to a new location
|
- PageLoadPre
- Triggered after a page load is initiated
|
- PageLoad
- Triggered when a page gets (re)loaded/opened
|
- PrivateMode
- Triggered when private mode is activated or deactivated
|
- Sanitize
- Triggered when privata data are sanitized
|
- ShellCmdPost
- Triggered after executing a shell command with :!{cmd}
|
- VimperatorEnter
- Triggered after Swiftweasel starts
|
- VimperatorLeavePre
- Triggered before exiting Swiftweasel, just before destroying each module
|
- VimperatorLeave
- Triggered before exiting Swiftweasel
|
{pat} is a regular expression, use .* if you want to match all URLs.
Note: This differs from Vim which uses a glob rather than a regex for
{pat}.
The following keywords are available where relevant:
- <url>
- The URL against which the event was selected.
|
- <title>
- The page, bookmark or download title.
|
- <doc>
- The document for which the event occurred. Only for DOMLoad, PageLoad and PageLoadPre.
|
- <tab>
- The tab in which the event occurred. Only for DOMLoad, PageLoad and PageLoadPre.
|
- <tags>
- The tags applied to <url>. Only for BookmarkAdd.
|
- <keyword>
- The keywords applied to the bookmark. Only for BookmarkAdd.
|
- <icon>
- The icon associated with <url>. Only for BookmarkAdd.
|
- <size>
- The size of a downloaded file. Only for DownloadPost.
|
- <file>
- The target destination of a download. Only for DownloadPost.
|
- <state>
- The new state. Only for "Fullscreen" and PrivateMode.
|
- <name>
- The name of the item. Only for ColorScheme and Sanitize.
|
:doautoa[ll] {event} [url]
Apply the autocommands matching the specified URL to all buffers. If no
[url] is specified use the current URL.
:do[autocmd] {event} [url]
Apply the autocommands matching the specified URL to the current buffer. If no
[url] is specified use the current URL.
Enable passthrough mode on all Google sites:
:autocmd LocationChange .* js modes.passAllKeys = /google\.com/.test(buffer.URL)
Enable passthrough mode on some Google sites:
:autocmd LocationChange .* js modes.passAllKeys = /(www|mail)\.google\.com/.test(buffer.URL)
Set the filetype to mail when editing email at Gmail:
:autocmd LocationChange .* :set editor=gvim -f
:autocmd LocationChange mail\\.google\\.com :set editor=gvim -f -c 'set ft=mail'