Skip to content

Miscellaneous tweaks

Emily Marigold Klassen edited this page Jun 24, 2025 · 5 revisions

Line movement with line wrapping on

With line wrapping, j and k provide movement between lines. It's nice to be able to move between display lines. That's the default with VS Code's up and down arrows. That's the way it works in insert mode. To move between display lines, you can redefine j and k as:

    {
        "key": "j",
        "command": "cursorDown",
        "when": "editorTextFocus && dance.mode == 'normal' && editorWordWrap"
    },
    {
        "key": "k",
        "command": "cursorUp",
        "when": "editorTextFocus && dance.mode == 'normal' && editorWordWrap"
    },

This is adapted from a similar issue with VSCodeVim. Line wrapping is especially common in Markdown files. The downside with this is that you lose Dance features. Moving by ten lines with 10k doesn't work. shift-j/k work differently.

To regain these features, you can use the following configuration:

  {
    "key": "j",
    "command": "dance.run",
    "when": "editorTextFocus && dance.mode == 'normal' && !editorHasSelection && !editorHasMultipleSelections",
    "args": {
      "code": [
        "if (repetitions > 1) {",
        "  await vscode.commands.executeCommand('dance.select.down.jump', { count: repetitions })",
        "  if (Context.current.shouldRecord()) {",
        "    context.extension.recorder.recordCommand('dance.select.down.jump', { count: repetitions });",
        "  }",
        "} else {",
        "  vscode.commands.executeCommand('cursorDown')",
        "}"
      ]
    }
  },
  {
    "key": "k",
    "command": "dance.run",
    "when": "editorTextFocus && dance.mode == 'normal' && !editorHasSelection && !editorHasMultipleSelections",
    "args": {
      "code": [
        "if (repetitions > 1) {",
        "  await vscode.commands.executeCommand('dance.select.up.jump', { count: repetitions })",
        "  if (Context.current.shouldRecord()) {",
        "    context.extension.recorder.recordCommand('dance.select.up.jump', { count: repetitions });",
        "  }",
        "} else {",
        "  vscode.commands.executeCommand('cursorUp')",
        "}"
      ]
    }
  },

Clone this wiki locally