RMS Meta

RMS Meta

Code to cloud for people & nature

Blog · Dec 25, 2025

Mastering Vim: Concepts, Modes, Movement, and Everyday Workflows

Vim is a modal editor built for speed and precision. Once you grasp its modes, motion-centric editing, and a few power features, you can navigate and transform text faster than most GUI editors.

Core concepts

  • Modal editing: Normal (commands), Insert (typing), Visual (select), Command-line (: commands).
  • Composability: Operator + motion = action (e.g., d + w = delete word).
  • Buffers/Windows/Tabs: Buffer = an open file; Window = a view on a buffer; Tab = a collection of windows.

Modes and essentials

  • Normal: ESC (default). Navigate, edit with commands.
  • Insert: i (insert), a (append), o/O (new line below/above). ESC to return to Normal.
  • Visual: v (char), V (line), Ctrl+v (block). Then apply operators (yank, delete, indent).
  • Command-line: : for ex commands, / for search, ? for reverse search.

Movement (be fast here)

  • Basic: h j k l (left/down/up/right), w/b (word fwd/back), 0/$ (line start/end).
  • Sentences/paragraphs: (/), {/}.
  • File: gg (top), G (bottom), :{n} (go to line).
  • Find on line: f{char}/F (back), t{char}/T (till), ;/, to repeat.
  • Marks: ma (set mark a), 'a (jump to it). `` to jump back.

Editing with operators

  • Delete: d{motion} (e.g., dw, d$, di" to delete inside quotes).
  • Change: c{motion} (delete + go to Insert). ciw = change inner word.
  • Yank/Paste: y{motion}, p/P to paste.
  • Indent: >/< with motions or Visual selections.
  • Repeat: . repeats the last change—huge productivity win.

Text objects (power feature)

  • Inside/around: i/a + w (word), p (paragraph), ", ', (, {, [, <.
  • Examples: ci" (change inside quotes), da( (delete around parentheses), vip (select inner paragraph).

Search, replace, and navigation

  • Search: /pattern, n/N to move; */# to search word under cursor.
  • Substitute (line): :s/old/new/g. Whole file: :%s/old/new/gc (c to confirm).
  • Split windows: :sp (horizontal), :vsp (vertical); move with Ctrl+w + h/j/k/l.
  • Buffers: :ls to list, :b {num} to jump, :bd to close buffer.

Registers, undo, macros

  • Registers: "{reg}y to yank into a register (e.g., "ayw), "{reg}p to paste. "* and "+ for clipboard (if enabled).
  • Undo/redo: u (undo), Ctrl+r (redo). Undo tree exists; navigate with g-/g+.
  • Macros: q{reg} to start recording, do actions, q to stop, @{reg} to replay, @@ to repeat last macro.

Visual block superpowers

  • Ctrl+v to enter block mode; select a column; then I (insert) or A (append) to edit multiple lines at once.
  • Use block mode to prepend/append text, align columns, or comment/uncomment blocks.

Config and plugins

  • .vimrc/init.vim basics: set number, set relativenumber, set expandtab, set shiftwidth=2, set tabstop=2, set smartindent, set ignorecase smartcase, set incsearch, set hlsearch.
  • Plugins: Use a plugin manager (vim-plug, packer.nvim). Common picks: file explorer (netrw built-in, or NERDTree), fuzzy finder (fzf), LSP client (built-in for Neovim), treesitter for better syntax.
  • Mappings: Create leader shortcuts, e.g., let mapleader="," then nnoremap <leader>f :Files<CR> (with fzf).

Everyday workflows

  • Open files: vim file1 file2; switch buffers with :bnext/:bprev.
  • Split and compare: :vsp file, then use do/dp for diff or :diffthis/:diffoff.
  • Indent/format: gg=G to auto-indent whole file; language servers/formatters via LSP or :%!formatter.
  • Save/quit: :w, :q, :wq, :q!.

Muscle-memory tips

  • Use motions more than arrow keys: w, b, f/t, {/}.
  • Always try the operator + motion pattern before reaching for the mouse.
  • Lean on . to repeat edits and @ macros for repetitive work.

Master the modes, motions, and operator+motion mindset first. Then layer in searches, macros, splits, and a small set of configs. Vim rewards a few core habits with huge speed gains.