Fix VS Code Vim Mode Multi Cursor Glitches with One Tiny Tweak (Really)

Published September 20th, 2023
3 minute read

There are two vim emulator plugins for VS Code that are well known -- amVim and VsCodeVim. I've been using amVim for years, but discovered today that the other emulator works better with one tiny tweak to the default extension settings.

The Problem with VsCodeVim

It messes with the multi cursor features in VS Code.

Although I've happily been using amVim and even contributed to it, today I tried the Cursor editor again. Cursor installs VSCodeVim if you enable Vim bindings during setup. Initially I thought Cursor had a bug with multi-cursor selections, but it turns out it's still a problem with the default settings in the VSCodeVim extension.

Then I remembered this was the main reason for me using amVim forever.

Typically I select text, then press Cmd + D to select the next matches with multiple cursors. When VSCodeVim is enabled, this sometimes goes haywire.

Watch what happens when I try to select a few occurrences of ' in this video 👇
Notice how the selection changes and doesn't even select the right thing -- maddening!

The Fix

The VsCodeVim version binds a function to Cmd+D by default which competes with our other (default multi cursor) shortcut.

Follow these steps to fix it:

  1. Cmd+Shift+P to open the Command Palette, then search for shortcuts. The one you want is titled Preferences: Open Keyboard Shortcuts.
  2. In the shortcuts panel, search for "Cmd+D" (yes, with the quotes). This shows all shortcuts bound to that key combination.
  3. Right click on the row with the command extension.vim_cmd+d and choose Remove Keybinding.
  4. Enjoy Vim! ✌️

Fixed. Feels goooood. 👇

Why Switch Now?

You might be wondering, "what's the point of switching?" Well, VsCodeVim has much more complete Vim implementation, and amVim doesn't get a ton of updates nowadays. For example, these are a few of the things amVim doesn't have (at this time):

  • Support for navigating up and down by page Ctrl + U, Ctrl + D
  • Support for macros and registers (yes, you can record macros with VsCodeVim 🤯)
  • Vim-style searching (and match navigation) instead of / being a shortcut to open the VS Code search. Gonna use this a ton.
  • Jump points work! :ju to see them all, Ctrl + o to go back, Ctrl + i to go forward
  • Automatic detection of nearest text objects like quotes and tags

Will update this article with any other notable feature differences or annoyances I encounter. Thanks for reading!

👋 Happy Coding!

Enjoy this article? Follow me on Twitter for more tips, articles and links.
😢 Awww, nobody has liked or mentioned this on Twitter yet.

Want Updates?

Sign up here if you want to stay in the loop about new articles or products I'm making.
I'll never spam you. Unsubscribe at any time.
Copyright ©2024 Austen Cameron