As the time of writing this article, 27 Sept 2022, doing vscode-vim setup is still a pretty painful step in macOS and in windows. This article is a compilation of pains that I experienced during using the extension and how to “fix” them
Before this post, I learned about how to use vim and come to love some of it features. I want to keep using the features that was available and combine it with vscode. Thankfully, there is an extension called vscode-vim that does the job for me. But, upon using it, I discovered that there is a lot of conflicts between vscode shortcuts that I often use and vim shortcuts. So, here are the list of commands that was “buggy” for me and how to “fix” it.
I’ll use mac terminology for this article. For those working with windows / other systems, replace the word “Command” with “Control”. Some of those shortcuts might not be conflicting in other systems.
Command + d (Select next occurrence)
command (or control) + D is the shortcut for selecting the next occurrence in vscode
it is also the shortcut for navigating half a page down in vim
To fix the bug, simply change the keyboard shortcut for cmd+D in vim (
keyboard shortcuts →
extension.vim_cmd+d → right click → remove keybinding or change keybinding)
After this step, there is still one annoying thing when you use
cmd+D . The mode will go to visual every time you do
cmd+d . As of the time of this article, there is no solution to disabling visual mode on selecting multiple stuffs, so you need to bear with it. (use
c to change whole text on selection).
Command + c (copy)
Same as above, it’s buggy because of conflicting
cmd+c key for vim. So simply change vim
cmd+c keyboard shortcut (
Cursor select when using up/down arrow keys
When using up/down arrow keys, the cursor suddenly selects stuffs for a bit then it de-select it. I don’t know why this happens, but I resolved it by removing the keyboard shortcut for
Update: Left & Right Arrow Key
5 Oct 2022, found another inconveniences which is the left & right arrow key won’t go to the start or the end of the selection (original behavior), but will always go to the start/end of the cursor. If you prefer the original behavior, do the same thing as the above section (remove extension.vim_right and extension.vim_left keybindings)
Cannot go through collapsed block
Now this one needs a little bit of explanation. If I have code like this:
And I use vscode collapse/fold block feature ( cmd + option + [ ), it will look like this:
and if, my cursor is in the first line then I press down, the behavior that I’m used to is it skips the collapsed lines to the end of the block (it skips the 2nd line).
But when using vscode-vim the behavior changes to expanding the collapsed block then going to the first line of the block.
Now, if you don’t use vscode collapse/fold block feature, you should , and if you want to revert to the original behavior while using vscode-vim, do this steps in vscode:
cmd + shift + p →
Preferences: Open User Settings (JSON) → Add
vim.foldfix: trueproperty before the closing bracket, it should look like this:
Save the folder, then try doing fold + down key again. It should be fixed.
Escape button behavior on closing suggestions/hints
Usually, when closing hints or suggestions from vscode, I use the escape button. Now, because of vscode-vim, it also turns into the normal mode every time I do this, which is not my preferred behavior.
To revert to the original behavior without going back to insert mode, do this steps:
keyboard shortcuts → search
extension.vim_escape → right click → Change When Expression → add
&& !parameterHintsVisible && !suggestWidgetVisible to the when expression → Enter
This will basically make vim not go into normal mode when we are hitting escape whenever hints or suggestions from vscode is visible.
Tab button behavior
Updated on 8/12/2022. The tab button seems to not work as intended as well. For example, indenting a whole paragraph does not work after installing vim. To make the tab behaves like usual, go to keyboard_shortcuts → search “vim tab” → right-click the command → remove keybinding. Both shift-tab and tab do not behave as intended.
Extra: Start In Insert Mode
Whenever you visit a new file, the cursor always go to normal mode by default by vscode-vim (and vim too ofc). To start in insert mode by default, add this line to
User Settings (JSON) :
And that’s all the setup I do for vscode-vim for now. I might add to this list in the future so do follow + clap if this article helps. Thanks for reading the article.