THX1137
THX1137

Reputation: 973

How Do I Map Ctrl-f To Move Forward A Character In VS Code?

I have gotten into the habit of using ctrl+f to move forward a character when staying in insert mode while using the vim mode in various editors. I don't like using the arrow keys or hopping out of insert mode/moving a character with a motion command/getting back into insert mode. How do I make that shortcut work in VS Code? I also often will use ctrl+b to move backwards a character, but this is less important. I'm open to other suggestions, btw, for moving around while in insert mode without the arrow keys.

Upvotes: 1

Views: 1787

Answers (1)

Mark
Mark

Reputation: 181349

In keybindings.json:

{
    "key": "ctrl+f",
    "command": "cursorRight",
    "when": "editorTextFocus"
  },
  {
    "key": "right",
    "command": "-cursorRight",
    "when": "editorTextFocus"
  }

Steps to reproduce:

  1. Ctrl-K Ctrl-S opens keyboard shortcuts (or click the gear icon in lower left).

  2. Search for cursor right.

  3. Mouseover "cursor right", click on "+" or "pen" edit icon.

  4. Enter your desired keybinding in the popup dialog, press enter.

  5. Vscode will automatically produce the keybindings above in your keybindings.json file.

Upvotes: 4

Related Questions