.. | ||
evil-dance.md | ||
README.md |
Recipes
This directory contains Dance "recipes" -- example configurations and commands meant to show what can be done with Dance.
For more examples, please see the test suite and the Dance API documentation, both of which contain many different tested examples.
Enabling or disabling Dance
Unlike, say, VSCodeVim, Dance does not
provide a "disable Dance" command or option. This is by design, since Dance
features can be selectively disabled by using a custom mode. For instance, we
can define a dummy disabled
mode that will not respond to any default Dance
keybinding:
settings.json
:
"dance.modes": {
"disabled": {},
},
keybindings.json
:
{
"key": "...",
"command": "dance.modes.set",
"args": {
"input": "disabled"
},
"when": "dance.mode != 'disabled'",
},
{
"key": "...",
"command": "dance.modes.set",
"args": {
"input": "normal"
},
"when": "dance.mode == 'disabled'",
},
An advantage of using modes rather than a complete "disable Dance" command is
that other Dance features, such as dance.run
and dance.openMenu
, can keep
working. If you truly want to completely disable Dance for some reason, please
disable it from the VS Code extensions panel.
Generating code using commented JavaScript code
The following script can be used:
await run(Selections.map((text) => text.replace(/^\/\/ |START$[\s\S]+?END$/gm, "")));
Before:
// await replace((text) => text.replace(/(\/\/ START\n)([\s\S]+?)(\/\/ END\n)/m, (_, before, after) =>
^
// before + "const alphabet = " + JSON.stringify(
// Array.from({ length: 26 }, (_, i) => String.fromCharCode(97 + i)),
// undefined, 2,
// ) + "\n" + after);
// START
// END
^ 0
After:
// await replace((text) => text.replace(/(\/\/ START\n)([\s\S]+?)(\/\/ END\n)/m, (_, before, after) =>
^
// before + "const alphabet = " + JSON.stringify(
// Array.from({ length: 26 }, (_, i) => String.fromCharCode(97 + i)),
// undefined, 2,
// ) + ";\n" + after);
// START
const alphabet = [
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
"x",
"y",
"z"
];
// END
^ 0
Using jj
to escape insert
mode
Using the prefix
argument of the dance.openMenu
command:
{
"key": "j",
"command": "dance.openMenu",
"args": {
"menu": {
"items": {
"j": {
"text": "escape to Normal",
"command": "dance.modes.set.normal",
},
},
},
"prefix": "j",
},
"when": "editorTextFocus && dance.mode == 'insert'",
}
For more information, please refer to this issue.