- 📃 Our change log outlines the breaking/major/minor updates between releases.
- Report missing features/bugs on GitHub.
- 💾 Installation
- ⚙️ Settings
- Quick Example
- VSCodeVim settings
- Neovim Integration
- Key Remapping
"vim.insertModeKeyBindings"/"vim.normalModeKeyBindings"/"vim.visualModeKeyBindings"/"vim.operatorPendingModeKeyBindings""vim.insertModeKeyBindingsNonRecursive"/"normalModeKeyBindingsNonRecursive"/"visualModeKeyBindingsNonRecursive"/"operatorPendingModeKeyBindingsNonRecursive"- Debugging Remappings
- Remapping more complex key combinations
- Vim modes
- Vim settings
- .vimrc support
- 🖱️ Multi-Cursor Mode
- 🔌 Emulated Plugins
- 🎩 VSCodeVim tricks!
- 📚 F.A.Q.
- ❤️ Contributing
💾 Installation
VSCodeVim can be installed via the VS Code Marketplace or the OpenVSX Marketplace.
Mac
To enable key-repeating, execute the following in your Terminal, log out and back in, and then restart VS Code:
defaults write com.microsoft.VSCode ApplePressAndHoldEnabled -bool false # For VS Code
defaults write com.microsoft.VSCodeInsiders ApplePressAndHoldEnabled -bool false # For VS Code Insider
defaults write com.vscodium ApplePressAndHoldEnabled -bool false # For VS Codium
defaults write com.microsoft.VSCodeExploration ApplePressAndHoldEnabled -bool false # For VS Codium Exploration users
defaults write com.exafunction.windsurf ApplePressAndHoldEnabled -bool false # For Windsurf
defaults delete -g ApplePressAndHoldEnabled # If necessary, reset global default
We also recommend increasing Key Repeat and Delay Until Repeat settings in System Settings/Preferences -> Keyboard.
Windows
Like real vim, VSCodeVim will take over your control keys. This behavior can be adjusted with the useCtrlKeys and handleKeys settings.
⚙️ Settings
The settings documented here are a subset of the supported settings; the full list is described in the FEATURES -> Settings tab of VSCodeVim's extension details page, which can be found in the extensions view of VS Code.
Quick Example
Below is an example of a settings.json file with settings relevant to VSCodeVim:
{
"vim.easymotion": true,
"vim.incsearch": true,
"vim.useSystemClipboard": true,
"vim.useCtrlKeys": true,
"vim.hlsearch": true,
"vim.insertModeKeyBindings": [
{
"before": ["j", "j"],
"after": ["<Esc>"]
}
],
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": ["<leader>", "d"],
"after": ["d", "d"]
},
{
"before": ["<C-n>"],
"commands": [":nohl"]
},
{
"before": ["K"],
"commands": ["lineBreakInsert"],
"silent": true
}
],
"vim.leader": "<space>",
"vim.handleKeys": {
"<C-a>": false,
"<C-f>": false
},
// To improve performance
"extensions.experimental.affinity": {
"vscodevim.vim": 1
}
}
VSCodeVim settings
These settings are specific to VSCodeVim.
Neovim Integration
:warning: Experimental feature. Please leave feedback on neovim integration here.
To leverage neovim for Ex-commands,
- Install neovim
- Modify the following configurations:
Here's some ideas on what you can do with neovim integration:
- The power of g
- The :normal command
- Faster search and replace!
Key Remapping
Custom remappings are defined on a per-mode basis.
"vim.insertModeKeyBindings"/"vim.normalModeKeyBindings"/"vim.visualModeKeyBindings"/"vim.operatorPendingModeKeyBindings"
- Keybinding overrides to use for insert, normal, operatorPending and visual modes.
- Keybinding overrides can include
"before","after","commands", and"silent". - Bind
jjto<Esc>in insert mode:
"vim.insertModeKeyBindings": [
{
"before": ["j", "j"],
"after": ["<Esc>"]
}
]
- Bind
£to goto previous whole word under cursor:
"vim.normalModeKeyBindings": [
{
"before": ["£"],
"after": ["#"]
}
]
- Bind
:to show the command palette, and don't show the message on the status bar:
"vim.normalModeKeyBindings": [
{
"before": [":"],
"commands": [
"workbench.action.showCommands",
],
"silent": true
}
]
- Bind
<leader>mto add a bookmark and<leader>bto open the list of all bookmarks (using the Bookmarks extension):
"vim.normalModeKeyBindings": [
{
"before": ["<leader>", "m"],
"commands": [
"bookmarks.toggle"
]
},
{
"before": ["<leader>", "b"],
"commands": [
"bookmarks.list"
]
}
]
- Bind
ctrl+nto turn off search highlighting and<leader>wto save the current file:
"vim.normalModeKeyBindings": [
{
"before":["<C-n>"],
"commands": [
":nohl",
]
},
{
"before": ["leader", "w"],
"commands": [
"workbench.action.files.save",
]
}
]
- Bind
{towin operator pending mode makesy{andd{work likeywanddwrespectively:
"vim.operatorPendingModeKeyBindings": [
{
"before": ["{"],
"after": ["w"]
}
]
- Bind
Lto$andHto^in operator pending mode makesyLanddHwork likey$andd^respectively:
"vim.operatorPendingModeKeyBindings": [
{
"before": ["L"],
"after": ["$"]
},
{
"before": ["H"],
"after": ["^"]
}
]
- Bind
>and<in visual mode to indent/outdent lines (repeatable):
"vim.visualModeKeyBindings": [
{
"before": [
">"
],
"commands": [
"editor.action.indentLines"
]
},
{
"before": [
"<"
],
"commands": [
"editor.action.outdentLines"
]
},
]
- Bind
<leader>vimto clone this repository to the selected location:
"vim.visualModeKeyBindings": [
{
"before": [
"<leader>", "v", "i", "m"
],
"commands": [
{
"command": "git.clone",
"args": [ "https://github.com/VSCodeVim/Vim.git" ]
}
]
}
]
"vim.insertModeKeyBindingsNonRecursive"/"normalModeKeyBindingsNonRecursive"/"visualModeKeyBindingsNonRecursive"/"operatorPendingModeKeyBindingsNonRecursive"
- Non-recursive keybinding overrides to use for insert, normal, and visual modes
- Example: Exchange the meaning of two keys like
jtokandktojto exchange the cursor up and down commands. Notice that if you attempted this binding normally, thejwould be replaced withkand thekwould be replaced withj, on and on forever. When this happens 'maxmapdepth' times (default 1000) the error message 'E223 Recursive Mapping' will be thrown. Stop this recursive expansion using the NonRecursive variation of the keybindings:
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": ["j"],
"after": ["k"]
},
{
"before": ["k"],
"after": ["j"]
}
]
- Bind
(to 'i(' in operator pending mode makes 'y(' and 'c(' work like 'yi(' and 'ci(' respectively:
"vim.operatorPendingModeKeyBindingsNonRecursive": [
{
"before": ["("],
"after": ["i("]
}
]
- Bind
pin visual mode to paste without overriding the current register:
"vim.visualModeKeyBindingsNonRecursive": [
{
"before": [
"p",
],
"after": [
"p",
"g",
"v",
"y"
]
}
],
Debugging Remappings
-
Adjust the extension's logging level to 'debug' and open the Output window:
- Run
Developer: Set Log Levelfrom the command palette. - Select
Vim, thenDebug - Run
Developer: Reload window - In the bottom panel, open the
Outputtab and selectVimfrom the dropdown selection.
- Run
-
Are your configurations correct?
As each remapped configuration is loaded, it is logged to the Vim Output panel. Do you see any errors?
debug: Remapper: normalModeKeyBindingsNonRecursive. before=0. after=^. debug: Remapper: insertModeKeyBindings. before=j,j. after=<Esc>. error: Remapper: insertModeKeyBindings. Invalid configuration. Missing 'after' key or 'commands'. before=j,k.Misconfigured configurations are ignored.
-
Does the extension handle the keys you are trying to remap?
VSCodeVim explicitly instructs VS Code which key events we care about through the package.json. If the key you are trying to remap is a key in which vim/vscodevim generally does not handle, then it's most likely that this extension does not receive those key events from VS Code. In the Vim Output panel, you should see:
debug: ModeHandler: handling key=A. debug: ModeHandler: handling key=l. debug: ModeHandler: handling key=<BS>. debug: ModeHandler: handling key=<C-a>.As you press the key that you are trying to remap, do you see it outputted here? If not, it means we don't subscribe to those key events. It is still possible to remap those keys by using VSCode's keybindings.json (see next section: Remapping more complex key combinations).
Remapping more complex key combinations
It is highly recommended to remap keys using vim commands like "vim.normalModeKeyBindings" (see here). But sometimes the usual remapping commands are not enough as they do not support every key combinations possible (for example Alt+key or Ctrl+Shift+key). In this case it is possible to create new keybindings inside keybindings.json. To do so: open up keybindings.json in VSCode using CTRL+SHIFT+P and select Open keyboard shortcuts (JSON).
You can then add a new entry to the keybindings like so:
{
"key": "YOUR_KEY_COMBINATION",
"command": "vim.remap",
"when": "inputFocus && vim.mode == 'VIM_MODE_YOU_WANT_TO_REBIND'",
"args": {
"after": ["YOUR_VIM_ACTION"]
}
}
For example, to rebind ctrl+shift+y to VSCodeVim's yy (yank line) in normal mode, add this to your keybindings.json:
{
"key": "ctrl+shift+y",
"command": "vim.remap",
"when": "inputFocus && vim.mode == 'Normal'",
"args": {
"after": ["y", "y"]
}
}
If keybindings.json is empty the first time you open it, make sure to add opening [ and closing ] square brackets to the file as the keybindings should be inside a JSON Array.
Vim modes
Here are all the modes used by VSCodeVim:
When rebinding keys in keybindings.json using "when clause context", it can be useful to know in which mode vim currently is. For example to write a "when clause" that checks if vim is currently in normal mode or visual mode it is possible to write the following:
"when": "vim.mode == 'Normal' || vim.mode == 'Visual'",
Vim settings
Configuration settings that have been copied from vim. Vim settings are loaded in the following sequence:
:set {setting}vim.{setting}from user/workspace settings.- VS Code settings
- VSCodeVim default values
.vimrc support
:warning: .vimrc support is currently experimental. Only remaps are supported, and you may experience bugs. Please report them!
Set vim.vimrc.enable to true and set vim.vimrc.path appropriately.
🖱️ Multi-Cursor Mode
:warning: Multi-Cursor mode is experimental. Please report issues in our feedback thread.
Enter multi-cursor mode by:
- On OSX,
cmd-d. On Windows,ctrl-d. gb, a new shortcut we added which is equivalent tocmd-d(OSX) orctrl-d(Windows). It adds another cursor at the next word that matches the word the cursor is currently on.- Running "Add Cursor Above/Below" or the shortcut on any platform.
Once you have multiple cursors, you should be able to use Vim commands as you see fit. Most should work; some are unsupported (ref PR#587).
- Each cursor has its own clipboard.
- Pressing Escape in Multi-Cursor Visual Mode will bring you to Multi-Cursor Normal mode. Pressing it again will return you to Normal mode.
🔌 Emulated Plugins
vim-airline
:warning: There are performance implications to using this plugin. In order to change the status bar, we override the configurations in your workspace settings.json which results in increased latency and a constant changing diff in your working directory (see issue#2124).
Change the color of the status bar based on the current mode. Once enabled, configure "vim.statusBarColors". Colors can be defined for each mode either as string (background only), or string[] (background, foreground).
"vim.statusBarColorControl": true,
"vim.statusBarColors.normal": ["#8FBCBB", "#434C5E"],
"vim.statusBarColors.insert": "#BF616A",
"vim.statusBarColors.visual": "#B48EAD",
"vim.statusBarColors.visualline": "#B48EAD",
"vim.statusBarColors.visualblock": "#A3BE8C",
"vim.statusBarColors.replace": "#D08770",
"vim.statusBarColors.commandlineinprogress": "#007ACC",
"vim.statusBarColors.searchinprogressmode": "#007ACC",
"vim.statusBarColors.easymotionmode": "#007ACC",
"vim.statusBarColors.easymotioninputmode": "#007ACC",
"vim.statusBarColors.surroundinputmode": "#007ACC",
vim-easymotion
Based on vim-easymotion and configured through the following settings:
Once easymotion is active, initiate motions using the following commands. After you initiate the motion, text decorators/markers will be displayed and you can press the keys displayed to jump to that position. leader is configurable and is \ by default.
<leader><leader> (2s|2f|2F|2t|2T) <char><char> and <leader><leader><leader> bd2t <char>char> are also available.
The difference is character count required for search.
For example, <leader><leader> 2s <char><char> requires two characters, and search by two characters.
This mapping is not a standard mapping, so it is recommended to use your custom mapping.
vim-surround
Based on surround.vim, the plugin is used to work with surrounding characters like parentheses, brackets, quotes, and XML tags.
t or < as <desired> or <existing> will enter tag entry mode. Using <CR> instead of > to finish changing a tag will preserve any existing attributes.
Some examples:
"test"with cursor inside quotes typecs"'to end up with'test'"test"with cursor inside quotes typeds"to end up withtest"test"with cursor inside quotes typecs"tand enter123>to end up with<123>test</123>
vim-commentary
Similar to vim-commentary, but uses the VS Code native Toggle Line Comment and Toggle Block Comment features.
Usage examples:
gc- toggles line comment. For examplegccto toggle line comment for current line andgc2jto toggle line comments for the current line and the next two lines.gC- toggles block comment. For examplegCi)to comment out everything within parentheses.
vim-indent-object
Based on vim-indent-object, it allows for treating blocks of code at the current indentation level as text objects. Useful in languages that don't use braces around statements (e.g. Python).
Provided there is a new line between the opening and closing braces / tag, it can be considered an agnostic cib/ci{/ci[/cit.
vim-sneak
Based on vim-sneak, it allows for jumping to any location specified by two characters.
Once sneak is active, initiate motions using the following commands. For operators sneak uses z instead of s because s is already taken by the surround plugin.
CamelCaseMotion
Based on CamelCaseMotion, though not an exact emulation. This plugin provides an easier way to move through camelCase and snake_case words.
Once CamelCaseMotion is enabled, the following motions are available:
By default, <leader> is mapped to \, so for example, d2i\w would delete the current and next camelCase word segment.
Input Method
Disable input method when exiting Insert Mode.
Any third-party program can be used to switch input methods. The following will walkthrough the configuration using im-select.
-
Install im-select (see installation guide)
-
Find your default input method key
-
Mac:
Switch your input method to English, and run the following in your terminal:
/<path-to-im-select-installation>/im-selectto output your default input method. The table below lists the common English key layouts for MacOS. -
Windows:
Refer to the im-select guide on how to discover your input method key. Generally, if your keyboard layout is en_US the input method key is 1033 (the locale ID of en_US). You can also find your locale ID from this page, where the
LCID Decimalcolumn is the locale ID.
-
-
Configure
vim.autoSwitchInputMethod.-
MacOS:
Given the input method key of
com.apple.keylayout.USandim-selectlocated at/usr/local/bin. The configuration is:"vim.autoSwitchInputMethod.enable": true, "vim.autoSwitchInputMethod.defaultIM": "com.apple.keylayout.US", "vim.autoSwitchInputMethod.obtainIMCmd": "/usr/local/bin/im-select", "vim.autoSwitchInputMethod.switchIMCmd": "/usr/local/bin/im-select {im}" -
Windows:
Given the input method key of
1033(en_US) andim-select.exelocated atD:/bin. The configuration is:"vim.autoSwitchInputMethod.enable": true, "vim.autoSwitchInputMethod.defaultIM": "1033", "vim.autoSwitchInputMethod.obtainIMCmd": "D:\\bin\\im-select.exe", "vim.autoSwitchInputMethod.switchIMCmd": "D:\\bin\\im-select.exe {im}"
-
The {im} argument above is a command-line option that will be passed to im-select denoting the input method to switch to. If using an alternative program to switch input methods, you should add a similar option to the configuration. For example, if the program's usage is my-program -s imKey to switch input method, the vim.autoSwitchInputMethod.switchIMCmd should be /path/to/my-program -s {im}.
ReplaceWithRegister
Based on ReplaceWithRegister, an easy way to replace existing text with the contents of a register.
Once active, type gr (say "go replace") followed by a motion to describe the text you want replaced by the contents of the register.
vim-textobj-entire
Similar to vim-textobj-entire.
Adds two useful text-objects:
aewhich represents the entire content of a buffer.iewhich represents the entire content of a buffer without the leading and trailing spaces.
Usage examples:
dae- delete the whole buffer content.yie- will yank the buffer content except leading and trailing blank lines.gUae- transform the whole buffer to uppercase.
vim-textobj-arguments
Similar to the argument text object in targets.vim. It is an easy way to deal with arguments inside functions in most programming languages.
Usage examples:
cia- change the argument under the cursor while preserving separators like comma,.daa- will delete the whole argument under the cursor and the separators if applicable.
🎩 VSCodeVim tricks!
VS Code has a lot of nifty tricks and we try to preserve some of them:
gd- jump to definition.gq- on a visual selection reflow and wordwrap blocks of text, preserving commenting style. Great for formatting documentation comments.gb- adds another cursor on the next word it finds which is the same as the word under the cursor.af- visual mode command which selects increasingly large blocks of text. For example, if you had "blah (foo [bar 'ba|z'])" then it would select 'baz' first. If you pressedafagain, it'd then select [bar 'baz'], and if you did it a third time it would select "(foo [bar 'baz'])".gh- equivalent to hovering your mouse over wherever the cursor is. Handy for seeing types and error messages without reaching for the mouse!
📚 F.A.Q.
-
None of the native Visual Studio Code
ctrl(e.g.ctrl+f,ctrl+v) commands workSet the
useCtrlKeyssetting tofalse. -
Moving
j/kover folds opens up the foldsTry setting
vim.foldfixtotrue. This is a hack; it works fine, but there are side effects (see issue#22276). -
Key repeat doesn't work
Are you on a Mac? Did you go through our mac-setup instructions?
-
There are annoying intellisense/notifications/popups that I can't close with
<esc>! Or I'm in a snippet and I want to close intellisensePress
shift+<esc>to close all of those boxes. -
How can I use the commandline when in Zen mode or when the status bar is disabled?
This extension exposes a remappable command to show a VS Code style quick-pick version of the commandline, with more limited functionality. This can be remapped as follows in VS Code's keybindings.json settings file.
{ "key": "shift+;", "command": "vim.showQuickpickCmdLine", "when": "editorTextFocus && vim.mode != 'Insert'" }Or for Zen mode only:
{ "key": "shift+;", "command": "vim.showQuickpickCmdLine", "when": "inZenMode && vim.mode != 'Insert'" } -
How can I move the cursor by each display line with word wrapping?
If you have word wrap on and would like the cursor to enter each wrapped line when using j, k, ↓ or ↑, set the following in VS Code's keybindings.json settings file.
{ "key": "up", "command": "cursorUp", "when": "editorTextFocus && vim.active && !inDebugRepl && !suggestWidgetMultipleSuggestions && !suggestWidgetVisible" }, { "key": "down", "command": "cursorDown", "when": "editorTextFocus && vim.active && !inDebugRepl && !suggestWidgetMultipleSuggestions && !suggestWidgetVisible" }, { "key": "k", "command": "cursorUp", "when": "editorTextFocus && vim.active && !inDebugRepl && vim.mode == 'Normal' && !suggestWidgetMultipleSuggestions && !suggestWidgetVisible" }, { "key": "j", "command": "cursorDown", "when": "editorTextFocus && vim.active && !inDebugRepl && vim.mode == 'Normal' && !suggestWidgetMultipleSuggestions && !suggestWidgetVisible" }Caveats: This solution restores the default VS Code behavior for the j and k keys, so motions like . If you need these motions to work, .
❤️ Contributing
This project is maintained by a group of awesome people and contributions are extremely welcome :heart:. For a quick tutorial on how you can help, see our contributing guide.
Special shoutouts to:
- Thanks to @xconverge for making over 100 commits to the repo. If you're wondering why your least favorite bug packed up and left, it was probably him.
- Thanks to @Metamist for implementing EasyMotion!
- Thanks to @sectioneight for implementing text objects!
- Special props to Kevin Coleman, who created our awesome logo!
- Shoutout to @chillee aka Horace He for his contributions and hard work.