Skip to content

Instantly share code, notes, and snippets.

@rstacruz
Last active April 1, 2023 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rstacruz/a48d41de41af64d357f21264a9cdd5f2 to your computer and use it in GitHub Desktop.
Save rstacruz/a48d41de41af64d357f21264a9cdd5f2 to your computer and use it in GitHub Desktop.

Faster multi-line jumps in VSCode-Vim

One of the things that bothered me with VSCode-Vim was with how slow it was to use (number)(arrow) (eg, 42(down)) to move multiple lines down. In the screencast below, notice how it goes line-by-line rather than skipping ahead instantly.

☝ Figure 1: VSCode scrolls slooowly line-by-line when pressing 42(down).

Update (March 2023)

Configure the following in your settings.json and then reload window or restart:

"extensions.experimental.affinity": {
	"vscodevim.vim": 1
},

This makes the extension run on its own thread. Note that it's not going to be significantly faster (and probably won't be noticeable in most cases).

See: microsoft/vscode#65876 (comment)

Warning All info below were last updated in 2022. They're outdated as of March 2023.


Solution: use j/k

TIL that VSCode-Vim already accounts for this with hjkl movements, so 42(down) can be pressed at 42j.

☝Figure 2: Using j/k keys (eg, 3j instead of 3(down)) hops to the target line instantly. I also did a trick to make this work with arrow keys (see below).

Making it work with arrow keys

To make this work with (up) and (down) arrow keys too, I rebound my arrow keys to j/k movements.

/* settings.json */
{
  "vim.normalModeKeyBindings": [
    // Make "9j 9k" work faster
    { "before": ["Down"], "after": ["j"] },
    { "before": ["Up"], "after": ["k"] },
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment