Vim mode for VSCode, powered by Neovim
VSCode Neovim Integration
Neovim is a fork of Vim to allow greater extensibility and integration. This extension uses a fully embedded Neovim instance, no more half-complete Vim emulation! VSCode's native functionality is used for insert mode and VSCode commands, making the best use of both editors.
init.lua and most Nvim plugins.Table of Contents
C:\Neovim\bin\nvim.exe or /usr/local/bin/nvim.vscode-neovim.neovimExecutablePaths.win32vscode-neovim.neovimExecutablePaths.linuxvscode-neovim.neovimExecutablePaths.darwinuseWSL configuration toggle and specify the Linux path to the nvim
binary. wsl.exe Windows binary and wslpath Linux binary are required for this. wslpath must be available through
$PATH Linux env setting. Use wsl --list to check for the correct default Linux distribution.Snap Users: If you want to use Neovim from Snap, the Neovim path must be resolved to the snap binary location. On some systems it might be "
/snap/nvim/current/usr/bin/nvim". To check if you're running as a snap package, see ifwhich nvimresolves to/usr/bin/snap.
Since many Vim plugins can cause issues in VSCode, it is recommended to start from an empty init.vim. For a guide for
which types of plugins are supported, see troubleshooting.
Before creating an issue on Github, make sure you can reproduce the problem with an empty init.vim and no VSCode
extensions.
To detect if Nvim is running in VSCode, add to your init.vim:
if exists('g:vscode')
" VSCode extension
else
" ordinary Nvim
endifIn lua:
if vim.g.vscode then
-- VSCode extension
else
-- ordinary Nvim
endTo conditionally activate plugins, the best solution is to use the
LazyVim VSCode extra. However, packer.nvim and lazy.nvim have built-in
support for cond = vim.g.vscode and vim-plug has a
few solutions. See
plugins in the wiki for tips on configuring Vim plugins.
You can view all available settings and commands by opening the vscode-neovim extension details pane, and navigating to the features tab.
:e/:q/:vsplit/:tabnext/etc are mapped to corresponding VSCode
commands and behavior may be different (see below).:e in scripts/keybindings, they won't work. If you're using them in some custom
commands/mappings, you might need to rebind them to call VSCode commands from Neovim with
require('vscode').call() (see API).:w, :wa and :sav commands are supported and no longer alias to VSCode commands. You
can use them as you would in Neovim.abc<cursor> in insert mode, then move the cursor to a<cursor>bc and type 1 here
the repeat sequence would be 1. However, in VSCode, it would be a1bc. Another difference is that when you delete
some text in insert mode, dot repeat only works from right to left, meaning it will treat Del key as
BS keys when running dot repeat.Neovim: Restart Extension command to restart the extension.Output: Focus on Output View and select vscode-neovim logs.Debug, then click it again and choose
Set As Default.vscode-neovim.neovimClean in VSCode settings, which starts Nvim without your plugins (nvim --clean). Nvim
plugins can do anything. Visual effects in particular can cause visual artifacts. vscode-neovim does its best to
merge the visual effects of Nvim and VSCode, but it's far from perfect. You may need to disable some Nvim plugins that
cause visual effects.Unable to init vscode-neovim: command 'type' already exists message, uninstall other VSCode
extensions that use registerTextEditorCommand("type", …) (like
VSCodeVim or
Overtype).defaults write com.microsoft.VSCode ApplePressAndHoldEnabled -bool false."keyboard.dispatch": "keyCode".Developer: Toggle Keyboard Shortcuts Troubleshooting for tracing VSCode emitted keypresses and their processing
via defined keybindings.Developer: Inspect Key Mapping for getting the recognized mappings for the current keyboard layout inside
VSCode.If you have any performance problems (cursor jitter usually) make sure you're not using vim plugins that increase latency and cause performance problems.
Make sure to disable unneeded plugins, as many of them don't make sense with VSCode. Specifically, you don't need any code highlighting, completion, LSP plugins, or plugins that spawn windows/buffers (nerdtree , fuzzy-finders, etc). Most navigation/textobject/editing plugins should be fine.
For example, make sure you're not using anything that renders decorators very often:
If you're not sure, disable all other extensions, reload VSCode window, and see if the problem persists before reporting it.
Set with compositeKeys and tweak with compositeTimeout.
Examples: add to your settings.json:
jj to escape
{
"vscode-neovim.compositeKeys": {
"jj": {
"command": "vscode-neovim.escape",
},
},
}jk to escape and save
{
"vscode-neovim.compositeKeys": {
"jk": {
// Use lua to execute any logic
"command": "vscode-neovim.lua",
"args": [
[
"local code = require('vscode')",
"code.action('vscode-neovim.escape')",
"code.action('workbench.action.files.save')",
],
],
},
},
}VSCode's jumplist is used instead of Neovim's. This is to make VSCode native navigation (mouse click, jump to definition, etc) navigable through the jumplist.
Make sure to bind to workbench.action.navigateBack / workbench.action.navigateForward if you're using custom
mappings. Marks (both upper & lowercased) should work fine.
Multiple cursors work in:
To spawn multiple cursors from visual line/block modes type ma/mA or mi/mI (by default). The effect differs
bug: Cross-file global mark jump is overwritten by VS Code's previous cursor position
bug: taking over `type` breaks Copilot Chat newline bindings in chat input
Integrate Native Neovim Multicursor
refactor: eliminate postion/range/selection calculation logic
feature: Override neovim buffer commands & keymaps
marketplace publish: "PATs in Azure DevOps are retired"
bug: Enter (newline) doesn't work properly when splitting an editor
bug: 'z' is unconditionally swallowed in Windsurf Cascade chat input due to z-prefix list-fold chord
bug: Visual mode behaves incorrectly for unicode characters not in the basic multilingual plane
bug: remapping hjkl in nvim config leads to issues with visual mode