How to Use Vim Motions in VS Code
You don't have to choose between VS Code's excellent developer experience and Vim's legendary efficiency. The VS Code Vim extension brings the best of both worlds: lightning-fast Vim motions combined with modern IDE features like IntelliSense, debugging, and extensions.
This guide will show you exactly how to set up Vim motions in VS Code, configure the essential settings, and use the combination productively. Whether you're a Vim veteran looking for better tooling or a VS Code user curious about Vim efficiency, this is your complete roadmap.
Why VS Code + Vim = Perfect Combination
Let's be honest about the trade-offs:
✅ What VS Code Does Better
- Built-in debugging tools
- Extensive extension marketplace
- Excellent Git integration
- Modern UI and discoverability
- Language server protocol support
✅ What Vim Does Better
- Lightning-fast text navigation
- Powerful motion-based editing
- Modal editing efficiency
- Keyboard-only workflow
- Composable commands
The VS Code Vim extension gives you the best of both: you keep VS Code's modern features while gaining Vim's editing efficiency. It's not an emulation—it's a proper implementation of Vim motions that feels native.
Setting Up the Vim Extension in VS Code
Step 1: Install the Extension
The official Vim extension is maintained by VSCodeVim and has over 4 million installs. To install:
- Open VS Code
- Press
Ctrl+Shift+X(orCmd+Shift+Xon Mac) to open Extensions - Search for "Vim"
- Install the one by "vscodevim"
- Reload VS Code
That's it! Vim motions are now active. You'll start in Normal mode by default.
Step 2: Essential Settings Configuration
The default settings work fine, but these tweaks will make your experience much better. Open your settings.json file (Ctrl+Shift+P → "Preferences: Open Settings (JSON)") and add:
{
// Enable key repeat for macOS (allows holding down hjkl)
"vim.autoSwitchInputMethod.enable": true,
// Use system clipboard for yank/paste
"vim.useSystemClipboard": true,
// Show command in status bar
"vim.showcmd": true,
// Highlight search results
"vim.hlsearch": true,
// Incremental search (search as you type)
"vim.incsearch": true,
// Smart case searching
"vim.smartcase": true,
// Enable relative line numbers
"editor.lineNumbers": "relative",
// Smooth cursor animation
"editor.cursorBlinking": "solid",
"editor.cursorSmoothCaretAnimation": "on"
}Step 3: Enable Relative Line Numbers
Relative line numbers are a game-changer for Vim motions. They show the distance from your current line, making commands like 5j (down 5 lines) or 3dd (delete 3 lines) much more intuitive.
Add this to your settings.json:
{
"editor.lineNumbers": "relative"
}Now you can see at a glance how many lines up or down your target is. Want to jump 8 lines down? Just press 8j.
Step 4: Key Repeat Settings (macOS Only)
On macOS, holding down keys triggers the character picker instead of repeating. To enable key repeat for Vim motions, run this in Terminal:
defaults write com.microsoft.VSCode ApplePressAndHoldEnabled -bool falseRestart VS Code, and now you can hold down j to scroll down continuously.
Core Vim Motions That Work Perfectly in VS Code
Almost all standard Vim motions work in VS Code. Here are the ones you'll use most:
🎯 Navigation Motions
hjkl– Basic directional movementw, e, b– Word navigation0, ^, $– Line navigationgg, G– Jump to file start/end/, ?– Search forward/backwardf, F, t, T– Find character in line
Practice these on VimGym to build muscle memory.
✏️ Editing Commands
i, a– Insert before/after cursoro, O– Create new linex, dd– Delete character/linec, d+ motion – Change/delete with precisiony, p– Yank (copy) and put (paste)u, Ctrl+r– Undo/redo
👁️ Visual Mode Selections
v– Character-wise selectionV– Line-wise selectionCtrl+v– Block-wise selection (multi-cursor magic!)
Practice visual mode on VimGym.
What's Different from Native Vim?
About 98% of Vim motions work identically. A few things behave slightly differently:
- Buffers: VS Code uses tabs/editors instead of Vim buffers
- Windows: VS Code split view works differently
- Registers: Most work, but some edge cases differ
- Ex commands: Limited support (use VS Code's command palette instead)
In practice, these differences rarely matter. The core editing motions—the ones you use 99% of the time—work perfectly.
Advanced VS Code + Vim Features
Multiple Cursors with Vim Motions
This is where VS Code + Vim really shines. You can use Vim motions with multiple cursors:
- Enter visual block mode:
Ctrl+v - Select multiple lines:
jjj - Enter insert mode:
I - Type once, edit everywhere
Or use gb to add cursors at each search match. It's incredibly powerful.
Integrating with VS Code Commands
You can trigger VS Code commands from Vim's command line. Add these to your settings.json:
{
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": ["leader", "f"],
"commands": ["workbench.action.quickOpen"]
},
{
"before": ["leader", "p"],
"commands": ["workbench.action.showCommands"]
}
]
}Now Space+f opens file search and Space+p opens the command palette (assuming you set leader to Space).
Custom Keybindings
Map common actions to Vim-style shortcuts:
{
"vim.normalModeKeyBindings": [
{
"before": ["leader", "w"],
"commands": ["workbench.action.files.save"]
},
{
"before": ["leader", "q"],
"commands": ["workbench.action.closeActiveEditor"]
}
]
}Practice Setup: Building Muscle Memory
Having Vim motions available is great, but muscle memory comes from deliberate practice. Here's the strategy:
📅 Daily Practice Routine
- Morning: 10 minutes on VimGym exercises
- During Work: Use VS Code with Vim motions for real projects
- Evening: 5 minutes reviewing the cheat sheet
The key is using VimGym for focused practice, then applying those motions in your real VS Code workflow. The combination accelerates learning dramatically.
Gradual Transition Strategy
Don't try to learn everything at once. Follow this progression:
- Week 1: Just use
hjklfor navigation. Disable arrow keys. - Week 2: Add
w, e, bfor word navigation. - Week 3: Add
0, $, gg, Gfor jumping. - Week 4: Add editing commands like
d, c, y, p.
Troubleshooting Common Issues
❌ Keys Not Repeating on macOS
Run defaults write com.microsoft.VSCode ApplePressAndHoldEnabled -bool false in Terminal and restart VS Code.
❌ Extension Feels Slow
Disable other heavy extensions temporarily. The Vim extension is performant, but conflicts can cause lag.
❌ Can't Exit Insert Mode
Press Esc or Ctrl+[. If neither works, check for keybinding conflicts in VS Code settings.
❌ Clipboard Not Working
Add "vim.useSystemClipboard": true to your settings.json.
Start Your Vim + VS Code Journey Today
VS Code with Vim motions gives you the perfect balance: modern IDE features with legendary editing efficiency. You get IntelliSense, debugging, and a massive extension ecosystem, plus the speed and power of Vim motions.
The setup takes 5 minutes. The learning curve takes a few weeks of practice. But the productivity gains last your entire career.
Practice Vim Motions Right Now
Build muscle memory with our interactive exercises, then apply them in VS Code.
Start Free Exercises