placeholderVSCode VIM Part I - EasyMotion

VSCode VIM Part I - EasyMotion

Learn how to enhance VSCode text navigation by setting up EasyMotion with the VSCode Vim extension and LazyVim-like keybindings.

Preview

VS Code, as the number one IDE in the universe ☝🏻, still feels slightly worse than LazyVim for text jumping. I found that the VSCode Vim extension supports EasyMotion. With some keybinding tweaks, it can imitate LazyVim in a rough way. The result looks like this:

Of course, you can also install a Neovim extension and use LazyVim plugins directly inside VS Code. The Neovim extension is said to have better performance, though stability is not guaranteed.

Setup

Paste the following configuration into VS Code’s settings.json. It uses the Catppuccin Mocha theme, btw.

{  // leader key, set to the equals key here  "vim.leader": "=",  // Enable EasyMotion  "vim.easymotion": true,  // Catppuccin Mocha Color Scheme  "vim.easymotionDimBackground": true,  "vim.easymotionMarkerBackgroundColor": "#1e1e2e",  "vim.easymotionMarkerForegroundColorOneChar": "#f38ba8",  "vim.easymotionMarkerForegroundColorTwoCharFirst": "#fab387",  "vim.easymotionMarkerForegroundColorTwoCharSecond": "#f9e2af",  "vim.easymotionIncSearchForegroundColor": "#a6e3a1",  "vim.easymotionDimColor": "#6c7086",  "vim.easymotionMarkerFontWeight": "bold",  // LazyVim-Like Key Bindings  "vim.normalModeKeyBindings": [    {      "before": ["s"],      "after": ["<leader>", "<leader>", "/"]    },    {      "before": ["f"],      "after": ["<leader>", "<leader>", "f"]    },    {      "before": ["F"],      "after": ["<leader>", "<leader>", "F"]    }  ]}
Tip

If you are not used to Vim-style operations, you can use these extensions to achieve similar functionality:

The VSCode Vim extension probably does not support directly modifying EasyMotion keybindings. The configuration above is a workaround.
Take <ldr><ldr> / <char> ... <CR> as an example. Add a mapping in normalModeKeyBindings, so when s is pressed, it is replaced with <ldr><ldr> /, and then you can enter any character to search.

Keybinding Reference

Motion CommandDescription
<ldr><ldr> s <char>Search character
<ldr><ldr> f <char>Find character forwards
<ldr><ldr> F <char>Find character backwards
<ldr><ldr> t <char>Til character forwards
<ldr><ldr> T <char>Til character backwards
<ldr><ldr> wStart of word forwards
<ldr><ldr> bStart of word backwards
<ldr><ldr> lMatches beginning & ending of word, camelCase, after _, and after # forwards
<ldr><ldr> hMatches beginning & ending of word, camelCase, after _, and after # backwards
<ldr><ldr> eEnd of word forwards
<ldr><ldr> geEnd of word backwards
<ldr><ldr> jStart of line forwards
<ldr><ldr> kStart of line backwards
<ldr><ldr> / <char>... <CR>Search n-character
<ldr><ldr><ldr> bdtTil character
<ldr><ldr><ldr> bdwStart of word
<ldr><ldr><ldr> bdeEnd of word
<ldr><ldr><ldr> bdjkStart of line
<ldr><ldr><ldr> jJumpToAnywhere motion; default behavior matches beginning & ending of word, camelCase, after _ and after #

Ref

VSCodeVim/Vim: ⭐ Vim for Visual Studio Code
ggandor/leap.nvim: Neovim’s answer to the mouse 🦘