Vim motions in VS Code, JetBrains and Neovim
You don't have to leave your editor to use Vim motions. VS Code has two Vim extensions, VSCodeVim and VSCode Neovim. Every JetBrains IDE can run IdeaVim. Neovim needs nothing extra. In all of them w jumps to the next word, ciw changes the word under the cursor and . repeats your last change. The motions are the same everywhere. What changes is the setup, a few keys the editor wants for itself, and a few defaults.
Quick answers
| Editor | What to install | Where settings go |
|---|---|---|
| VS Code | the Vim extension (VSCodeVim, id vscodevim.vim) | VS Code's settings.json, as vim.* keys |
| VS Code, with Neovim behind it | the VSCode Neovim extension (id asvetliakov.vscode-neovim), plus Neovim itself | your Neovim init.lua |
| IntelliJ IDEA, PyCharm, WebStorm and the other JetBrains IDEs | the IdeaVim plugin, from Settings → Plugins → Marketplace | ~/.ideavimrc |
| Neovim | nothing | init.lua in the config folder (:echo stdpath('config') shows where it is) |
What carries over: everything the course teaches
These are core Vim commands, the part every Vim mode is built around. Learn them in one editor and they work in the others.
| Keys | What they do | Guide |
|---|---|---|
h j k l, 5j | move by character and line, with a count | Motions |
w b e ge, W B E gE | move by word | Motions |
0 ^ $ g_ | jump to the edges of the line | Motions |
f F t T ; , | jump to a character in the line | Motions |
gg G :42 | go to a line | Motions |
{ }, % | jump by paragraph, or to the matching bracket | Motions |
x X dd r ~ J gJ, u, Ctrl-r | small edits, undo and redo | Cheat sheet |
i a I A o O, Esc, R | enter and leave Insert mode (R enters Replace mode) | Cheat sheet |
d c y, D C cc s S, gu gU g~ | operators | Operators |
iw aw iW aW, i" a", i' a', i( a(, i{ a{, i[ a[ | text objects | Text objects |
y yy Y p P gp gP, . | yank, put and repeat | Copy and paste, dot command |
/ ? n N * # | search | Cheat sheet |
v V, U | Visual mode | Visual mode |
The grammar carries over too, and it matters more than any single key: an operator followed by a motion or a text object. Once you know d, w and iw, you also know dw, diw, ciw, yiw and gUiw, in every one of these editors.
The editors differ at the edges of Vim: Ex commands, options, macros, plugins. Each project documents what it supports, so check there before you rely on something unusual.
VS Code: VSCodeVim or VSCode Neovim
The two extensions take different approaches.
VSCodeVim (listed as "Vim" in the Marketplace) reimplements Vim inside VS Code. Install it and you start in Normal mode. Nothing else is needed. Some settings to know about:
"vim.useSystemClipboard": truemakes yank and put use the system clipboard, so text you copy withyypastes into other programs."vim.handleKeys"hands single Ctrl shortcuts back to VS Code.{ "<C-f>": false }keeps Ctrl-f as VS Code's Find."vim.useCtrlKeys"is on by default and lets the extension take Ctrl keys. Turn it off and VS Code gets them all back, including Ctrl-r, so Ctrl-r no longer redoes.- On macOS, holding
jopens the accent menu instead of repeating the key. VSCodeVim's README gives the fix: rundefaults write com.microsoft.VSCode ApplePressAndHoldEnabled -bool falsein a terminal, log out and back in, then restart VS Code.
VSCode Neovim embeds a real Neovim instance and sends your Normal-mode keys to it, so Normal-mode commands run in Neovim, with your config. Display and scrolling stay with VS Code: its README says line numbers and options like scrolloff are handled by VS Code, and that Ctrl-d and Ctrl-u scroll slightly differently. You install Neovim yourself (the README asks for 0.10.0 or newer). If the extension doesn't find it, give the full path in the extension's settings (vscode-neovim.neovimExecutablePaths.linux, .darwin or .win32). Insert mode is left to VS Code, so typing, autocomplete and snippets work as they always do. The extension loads your init.lua. Wrap settings and plugins that only make sense in a terminal in if not vim.g.vscode then ... end.
Which one should you pick? If you have never used Vim, VSCodeVim is the shorter path: one install, with settings in the same place as the rest of VS Code. If you already use Neovim, or want Neovim itself running your Normal mode, use VSCode Neovim. Install one, not both: they both take over VS Code's typing, and VSCode Neovim's README tells you to uninstall VSCodeVim if they clash.
JetBrains IDEs: IdeaVim
IdeaVim is JetBrains' own Vim plugin, and it works across their IDEs: IntelliJ IDEA, PyCharm, WebStorm, GoLand, Rider and the rest. Install it from Settings → Plugins → Marketplace. Its config file is ~/.ideavimrc, written like a vimrc:
let mapleader = " "
set relativenumber
set clipboard+=unnamed
nmap <leader>r <Action>(RenameElement)
set clipboard+=unnamed sends yanks to the system clipboard. <Action>(...) maps a key to any IDE action, here Rename, so Space r renames the symbol under the cursor. :actionlist lists the action ids you can use.
When a Ctrl shortcut belongs to both the IDE and Vim, IdeaVim lets you decide who gets it, one shortcut at a time. You can pick in IdeaVim's page in the IDE settings, or in ~/.ideavimrc with sethandler. sethandler <C-r> a:vim gives Ctrl-r to Vim in every mode.
Neovim: real Vim, with a few different defaults
Neovim started as a fork of Vim, and its motions and operators are the same. A few defaults differ from Vim and from what most tutorials (Vimrealm included) assume:
| Vim | Neovim | |
|---|---|---|
Y | copies the whole line, like yy | copies to the end of the line, like y$ |
gg, G, :42 | land on the first non-blank character | keep the cursor's column (startofline is off; :set startofline gives you Vim's behaviour) |
| Search highlighting | off unless you turn on hlsearch | on: matches stay lit until :nohlsearch or Ctrl-l |
Neovim lists these in :help vim-differences. It also ships :Tutor, which its own help describes as "a 30-minute tutorial that teaches the most basic Vim functionality hands-on". Vim's version of it is vimtutor, run from the shell.
The keys your editor wants for itself
Most Vim commands are plain letters, so they seldom clash with the editor. The clashes are on Ctrl keys, and the course teaches only one of those: Ctrl-r, redo.
| Editor | Ctrl-r without Vim | With Vim |
|---|---|---|
| VS Code | Open Recent | VSCodeVim takes it in Normal mode while vim.useCtrlKeys is on, which is the default. VSCode Neovim sends it to Neovim in Normal mode by default (its ctrlKeysForNormalMode setting includes r) |
| JetBrains IDEs | Replace (Windows and Linux keymaps) or Run context configuration (macOS keymap) | choose Vim in IdeaVim's settings, or add sethandler <C-r> a:vim |
| Neovim | redo | redo |
Every one of these editors also still accepts the arrow keys and the mouse. That's convenient, and it's also the problem the next section is about.
Practise somewhere else first
Finding out what w does takes a minute. The hard part of switching is the stretch when every edit is slower than it used to be, in the editor where you have real work to finish. The arrow keys and the mouse still work there, so under a deadline your hands go back to them, and the new habit never forms.
Practising somewhere else first changes three things. You can be slow, because nothing is at stake. You can take the old habits away. And you can be told when there was a shorter way.
vimtutor and Neovim's :Tutor are free and come with Vim and Neovim: a good first half hour. Vimrealm is a game built for the next step:
- The arrow keys are sealed. Pressing one gives a warning to use
h j k linstead. - Commands unlock chapter by chapter. Try one you haven't learned yet and the game tells you which chapter teaches it.
- Every quest has a par, a keystroke count taken from a reference solution. Finish at or under par for three stars, so you learn the short way and not just a way that works.
- The text panel shows relative line numbers, so you can read the count for
5jor3kstraight off the edge of the panel. Turn on the same thing in your editor:"editor.lineNumbers": "relative"in VS Code (with either extension),set relativenumberin IdeaVim and Neovim.
4k reaches the first import.A plan that works with any of these editors:
- Learn movement first:
h j k l, word motions, the edges of the line,fandt,ggandG. - Turn on Vim mode in your editor and use only those for a while, for normal work. Leave the arrow keys alone.
- Add operators and text objects. This is where combining keys starts to pay off.
- Then add yank and put, the dot command, search and Visual mode.
Practise Vim motions in Vimrealm
Vimrealm runs in your browser, with nothing to install, and follows that order. Chapters 1–5 teach every movement command from step 1 and are free, with no sign-up. Chapters 6–13 (edits, Insert mode, operators, text objects, yank and put, search and Visual mode) and the 60 post-game Trials are part of the full version ($7.99, one payment). Already know some Vim? A button on the quest map lets you skip ahead without clearing the earlier quests.
The game covers what the course teaches, not all of Vim. It has no macros, marks, named registers, ex ranges or :s, and its search matches literal text rather than regular expressions. You will meet those in your editor's Vim mode. See how the course works, or keep the cheat sheet open while you practise.