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

EditorWhat to installWhere settings go
VS Codethe Vim extension (VSCodeVim, id vscodevim.vim)VS Code's settings.json, as vim.* keys
VS Code, with Neovim behind itthe VSCode Neovim extension (id asvetliakov.vscode-neovim), plus Neovim itselfyour Neovim init.lua
IntelliJ IDEA, PyCharm, WebStorm and the other JetBrains IDEsthe IdeaVim plugin, from Settings → Plugins → Marketplace~/.ideavimrc
Neovimnothinginit.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.

KeysWhat they doGuide
h j k l, 5jmove by character and line, with a countMotions
w b e ge, W B E gEmove by wordMotions
0 ^ $ g_jump to the edges of the lineMotions
f F t T ; ,jump to a character in the lineMotions
gg G :42go to a lineMotions
{ }, %jump by paragraph, or to the matching bracketMotions
x X dd r ~ J gJ, u, Ctrl-rsmall edits, undo and redoCheat sheet
i a I A o O, Esc, Renter and leave Insert mode (R enters Replace mode)Cheat sheet
d c y, D C cc s S, gu gU g~operatorsOperators
iw aw iW aW, i" a", i' a', i( a(, i{ a{, i[ a[text objectsText objects
y yy Y p P gp gP, .yank, put and repeatCopy and paste, dot command
/ ? n N * #searchCheat sheet
v V, UVisual modeVisual 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:

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:

VimNeovim
Ycopies the whole line, like yycopies to the end of the line, like y$
gg, G, :42land on the first non-blank characterkeep the cursor's column (startofline is off; :set startofline gives you Vim's behaviour)
Search highlightingoff unless you turn on hlsearchon: 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.

EditorCtrl-r without VimWith Vim
VS CodeOpen RecentVSCodeVim 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 IDEsReplace (Windows and Linux keymaps) or Run context configuration (macOS keymap)choose Vim in IdeaVim's settings, or add sethandler <C-r> a:vim
Neovimredoredo

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:

A Vimrealm quest: the wizard on an isometric island of letter tiles, and below it the Scroll of Text with the cursor on line 5 and the lines around it numbered 4, 3, 2, 1 above and 1, 2, 3, 4 below.
Chapter 5, Paragraph Stride: the Scroll of Text numbers each line by its distance from the cursor, so 4k reaches the first import.

A plan that works with any of these editors:

  1. Learn movement first: h j k l, word motions, the edges of the line, f and t, gg and G.
  2. Turn on Vim mode in your editor and use only those for a while, for normal work. Leave the arrow keys alone.
  3. Add operators and text objects. This is where combining keys starts to pay off.
  4. 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.

Play Vimrealm free