Repeating commands

&dactyl.appName; can repeat commands in a number of ways, from repeating the last command, to recording and playing macros, to saving its state and executing scripts.

Single repeats

. count.

Repeat the last keyboard mapping count times. Note that, unlike in Vim, this does not apply solely to editing commands, mainly because &dactyl.appName; doesn't have them.

@: count@:

Repeat the last Ex command count times.

Macros

q q0-9a-zA-Z

Record a key sequence as a macro. Available macros are 0-9a-zA-Z. If the macro is an uppercase letter, the recorded keys are appended to the lowercase macro of the same name. Typing q again stops the recording.

:macros :macros pat

List recorded macros matching the optional regular expression pat. If no regexp is given, list all macros.

:delmac :delmacros :delmacros pat :delmacros!

Delete recorded macros matching the regular expression pat. If ! is given, all macros are deleted.

@ count@a-z0-9

Plays the contents of macro with name a-z0-9 count times.

@@ count@@

Replay the last executed macro count times.

Using scripts

:so :source :source! file

Read Ex commands, JavaScript, or CSS from file. Files are interpreted based on their extensions. Files which end in .js are executed as JavaScript, while those ending in .css are loaded as Cascading Stylesheets, and anything else is interpreted as Ex commands. In normal cases, any errors generated by the execution or non-existence of file are printed to the command-line area. When ! is provided, these are suppressed.

Environment variables in file are expanded to their current value, and the prefix ~ is replaced with the value of $HOME. See expand-env and initialization for more information.

Cascading Stylesheets

When a CSS file is sourced, its contents are applied to every web page and every chrome document, including all browser windows and dialogs. If the same file is sourced more than once, its previous rules are cleared before it is applied again. Rules can be restricted to specific documents by enclosing them in @-moz-document blocks.

JavaScript

JavaScript files are executed with full chrome privileges in their own global namespaces. These namespaces are stored as objects in the plugins object, in the property named after the full path of the sourced file. This means that any variables or functions created by your script are stored as properties of that object. Additionally, all properties of the global window and modules objects are accessible to your script as global variables.

Files in ~/.&dactyl.name;/plugins may additionally be accessed in plugins.filename where filename is the last component of the file's path stripped of any extensions, with all hyphens stripped and any letter following a hyphen capitalized. So, the file ~/.&dactyl.name;/plugins/foo-bar.js may be accessed as plugins.fooBar. See also writing-plugins

Ex commands

Ex command files are executed as if each line were entered into the &tag.command-line; individually. Additionally, certain commands support the same ‘here document’ syntax supported by most Unix shells and by the &tag.command-line;. So, to execute a JavaScript statement which does not comfortably fit on a single line, you can use

See also ex-scripts below.

:js <<EOF var hello = function () { alert(Hello world); } EOF
:lpl :loadplugins :loadplugins

Immediately load all plugins which have yet to be loaded. Because plugins are not automatically loaded until after &dactyl.name;rc is sourced, this command must be placed early in the &dactyl.name;rc file if &dactyl.name;rc uses commands or options which are defined by plugins. Additionally, this command allows newly installed plugins to be easily loaded without restarting &dactyl.appName;. See also loadplugins.

:ru :runtime :runtime! file

Source the specified file from the first directory in runtimepath in which it exists. When ! is given, source the file from all directories in runtimepath in which it exists.

:runtime plugins/foobar.js
:scrip :scriptnames :scriptnames

List all sourced script names, in the order they were first sourced.

:fini :finish :finish

Stop sourcing a script file. This can only be called from within a &dactyl.appName; script file.

Ex Command Scripts

Ex command scripts are similar to both entering commands on the &tag.command-line; and to Vim scripts, but with some notable differences.

Commands in Ex command scripts can span multiple lines by prefixing the second and further lines with a \ character. For instance, the following all define commands whose definitions span multiple lines.

:command! foo \ -description A command that frobs bars \ :javascript frob(content.bar) :style -name foo \ foobar.com \ p:first-line { font-variant: small-caps; } \ div#side-bar > :first-child { display: none; } :command! do-some-stuff \ -description A command which does some stuff in JavaScript \ :javascript <<EOF \ window.do(some); \ window.do(stuff); \EOF :command! do-some-stuff \ -description A command which does some stuff in JavaScript \ :javascript \\ window.do(some); \\ window.do(stuff);

Lines may be commented out by prefixing them with a " character.

" This is a comment foo bar " This is a comment This is not a comment foo bar This is not a comment

Profiling

:time :counttime! code|:command

Profile a piece of JavaScript code or an Ex command. Run code count times and print the elapsed time. If code begins with a :, it is executed as an Ex command. Otherwise, it is executed as JavaScript, in which case it is evaluated only once and stored as a function which is executed count times.

When ! is given, code is executed count times, but no statistics are printed.