Vim and Neovim Tutorial
Learn Vim and Neovim step by step: 36 lessons in 9 chapters with examples, quizzes, diagrams and projects.
Start learning →
of lessons completed
Getting Started
- What Is Vim? Modal Editing Explained Learn what Vim and Neovim are, why they use modes instead of menus, and how keyboard-first editing can make you faster. Includes a mode simulator.
- Installing Vim and Neovim, and Running vimtutor Install Vim or Neovim on Windows, macOS and Linux, check which features your build has, find your config files, and learn from vimtutor and :help.
- Your First Edit: Open, Type, Save, Quit Open a file in Vim, enter Insert mode, type, save with :w, quit with :q, and recover when you get stuck. Includes a buffer simulator to practice safely.
- The Vim Grammar: Operators, Counts and Motions Understand how Vim commands combine an optional count, an operator and a motion or text object, so a few keys unlock hundreds of commands. Includes a parser.
Modes and Navigation
- Vim Modes: Normal, Insert, Replace and Command-line Master Vim's modes: Normal, Insert, Replace, Command-line and Operator-pending. See how to switch, how Ctrl-o and Ctrl-c help, and practice with a simulator.
- Basic Vim Motions: h j k l, Words and Find Learn the core Vim motions: h j k l, word jumps w b e W B E, and character finds f t F T with ; and , repeats. Includes a runnable word-motion model.
- Vim Line, Paragraph and File Motions Move fast across whole lines and files in Vim: 0 ^ $, gg and G with counts, paragraph braces, % for matching pairs, H M L and scrolling keys.
- Vim Marks, the Jump List and the Change List Set marks with m, jump with ' and backtick, use global marks across files, and travel with Ctrl-o, Ctrl-i, g; and g, through the jump and change lists.
- Vim Visual Mode: Character, Line and Block Selection Select text with v, V and Ctrl-v, extend selections with motions and text objects, swap ends with o, edit many lines with block insert, and reselect with gv.
Editing and Text Objects
- Vim Operators and Motions in Depth Go deeper into Vim operators: delete, change, yank, indent, case and format; linewise versus characterwise motions; forcing motion types with v, V and Ctrl-v.
- Vim Text Objects: iw, i", i(, it and More Use Vim text objects such as iw, aw, i", a(, it and ip to change or delete structured text from anywhere inside it. Includes a runnable text object finder.
- Vim Change, Delete, Replace and Put Learn the everyday editing commands: x, dd, r, s, cw, cc, C, o and O, plus put with p and P, swapping text and the difference between change and replace.
- Vim Undo, Redo and the Dot Command Use u, Ctrl-r, U and the undo tree with g- and g+, understand undo steps, and repeat any change with the dot command for fast, repeatable editing.
- Vim Case, Join and Increment: Small Transformations Change case with ~ gu gU g~, join lines with J and gJ, increment and decrement numbers with Ctrl-a and Ctrl-x, sort, align and reformat quick edits in Vim.
Registers, Macros and Search
- Vim Registers: Yank, Delete History and Clipboard Understand Vim registers: the unnamed register, yank register 0, numbered delete history, named a-z registers, the system clipboard and the black hole.
- Vim Macros: Record, Replay and Edit Edits Record keystrokes with q, replay them with @ and @@, run a macro on many lines with counts and :normal, write recursive macros, and fix a macro as text.
- Searching in Vim: Patterns, Offsets and Highlights Search forward and backward with / and ?, repeat with n and N, use * and #, set ignorecase and smartcase, write Vim regex with \< \> and \v, and use offsets.
- Vim Substitute and Global: Find and Replace at Scale Master :s with ranges, flags and backreferences, confirm each change with c, and use :g and :v to run commands on matching lines. Includes runnable models.
Buffers, Windows and Tabs
- Buffers: Working With Many Files Understand Vim buffers: the difference between a file, a buffer and a window, how to list, switch and close buffers, the hidden option, and the alternate file.
- Windows and Splits Split the Vim screen horizontally and vertically, move between windows, resize and rearrange them, and learn the Ctrl-w command family with a layout simulator.
- Tab Pages and Layouts Learn Vim tab pages: create, switch, move and close them, when tabs beat buffers and splits, per-tab directories with :tcd, and how to label the tab line.
- The Argument List and the Quickfix List Run commands across many files with the argument list and the quickfix list: :args, :argdo, :vimgrep, :grep, :copen, :cdo, location lists and errorformat.
Configuration and Plugins
- Your vimrc and Options Create your Vim configuration file: where vimrc lives on Linux, macOS and Windows, how :set works, and the options almost everyone turns on, with explanations.
- Mappings and the Leader Key Create your own Vim shortcuts: map vs noremap, per-mode mapping commands, the leader key, special keys like <CR> and <Cmd>, timeouts, abbreviations and debugging.
- Autocommands and Vim Script Make Vim react to events with autocommands and augroup, and learn the Vim script basics (variables, lists, functions, user commands) needed to read and write a vimrc.
- Plugins and Packages Install and manage Vim plugins with native packages (pack/*/start and opt), vim-plug, how runtimepath works, helptags, colorschemes, netrw and startup time.
Neovim and Lua
- Neovim: What Is Different Learn what Neovim adds to Vim: Lua configuration, built-in LSP and Treesitter, a terminal, floating windows, XDG config paths, :checkhealth and how to migrate your vimrc.
- Lua for Neovim Users Learn the part of Lua you need for Neovim: variables, tables, functions, loops, modules with require, pcall and the gotchas that trip up newcomers, with runnable JS stand-ins.
- Writing init.lua Configure Neovim in Lua: vim.o, vim.opt and vim.g, vim.keymap.set, autocommands with vim.api, user commands, calling Vim script, and a clean multi-file layout.
- LSP, Tree-sitter and Plugin Managers Turn Neovim into an IDE-style editor: lazy.nvim plugin specs, the built-in LSP client, Tree-sitter highlighting, completion, fuzzy finding and what to install first.
Workflows
- Vim and the Terminal Work between Vim and the shell: run commands with :!, read output with :r !, filter lines through programs with !, use :terminal, :make, suspend with Ctrl-z and pair Vim with tmux.
- Vim and Git Use Vim with Git: write commit messages, compare files in diff mode (do, dp, ]c), resolve merge conflicts with vimdiff, and add vim-fugitive and gitsigns for a full workflow.
- Vi Keys Everywhere Take Vim's keys beyond the editor: vi mode in bash, zsh and readline, tmux copy mode, less and man, IdeaVim and VS Code, the command-line window, and browser extensions.
Projects and Practice
- Project: Build a Starter vimrc Build a clean, commented, version-controlled Vim configuration in stages: options, search, leader mappings, autocommands, a statusline and plugins, then lint it with a checker.
- Project: Refactor Text with Macros and :cdo A hands-on Vim project: clean a messy CSV and a code base using :g, :v, :normal, :s, recorded macros and :cdo, with a stand-in engine that lets you test each transformation.
- Practice: Vim Golf Challenges Practice Vim with golf-style challenges: transform text with the fewest keystrokes, compare solutions, learn the counting rules and check your answers with a stand-in verifier.