MeshWorld India LogoMeshWorld.
CheatsheetVimNeovimTerminalLinuxText EditorDeveloper Tools9 min read

Vim Cheat Sheet: Modes, Navigation, Editing & Config (2026)

Vishnu
By Vishnu
|Updated: Jul 30, 2026
Vim Cheat Sheet: Modes, Navigation, Editing & Config (2026)

Vim and Neovim remain the quintessential modal text editors for developers, platform engineers, and system administrators. Unlike standard GUI editors where keystrokes insert characters, Vim operates through specialized execution modes designed for high-speed text manipulation without touching the mouse.

Key Takeaways

  • Master Normal, Insert, Visual, and Command-Line modes for modal editing speed.
  • Learn shortcut commands to save and exit Vim cleanly (`:wq`, `:q!`, `ZZ`).
  • Leverage text objects (verb + modifier + noun, e.g. `ci"`, `da{`) to edit code blocks instantly.
  • Split windows (`:vsp`, `:sp`) and use tabs (`:tabnew`, `gt`) for high-density multi-file editing.
  • Automate repetitive multi-step edits across lines using registered macros (`qa`, `@a`).

What is the fundamental mode concept in Vim and Neovim?

Vim is a modal text editor where key behavior depends on the active mode. Pressing Esc always returns the editor to Normal mode, where keystrokes execute navigation and editing commands rather than typing text.

Modes Reference

KeyModeWhat you can do
(default)NormalNavigate, execute commands, manipulate text
iInsertType text before the cursor
aInsertType text after the cursor
AInsertType text at the end of the line
oInsertOpen a new line below and enter Insert mode
OInsertOpen a new line above and enter Insert mode
vVisualHighlight and select character blocks
VVisual LineHighlight and select entire lines
Ctrl+vVisual BlockHighlight and select rectangular columns
:CommandExecute Ex commands (:w, :q, :s)
/SearchSearch text forward
?SearchSearch text backward

Exiting Vim Shortcuts

CommandAction
:qQuit current window (only if no unsaved changes)
:q!Force quit immediately, discarding all unsaved changes
:wSave (write) changes without quitting
:wqSave changes and quit
:xSave changes and quit (identical to :wq)
ZZSave changes and quit (Normal mode shortcut)
ZQQuit without saving (Normal mode shortcut)

What are the most essential Vim movement and navigation commands?

Vim navigation relies on home-row keys (h, j, k, l) and word/line jump operators to move the cursor without mouse reliance.

Basic, Word & Page Movement

KeyMovement Action
h j k lMove Left · Down · Up · Right
wJump forward to the start of the next word
WJump forward to the next WORD (space-delimited)
bJump backward to the start of the previous word
eJump forward to the end of the word
0Jump to the absolute start of the line
^Jump to the first non-blank character of the line
$Jump to the end of the line
ggJump to the first line of the file
GJump to the last line of the file
:5 or 5GJump directly to line 5
Ctrl+dScroll down half a page
Ctrl+uScroll up half a page
Ctrl+fScroll down full page
Ctrl+bScroll up full page
zzRecenter screen view around the cursor
%Jump between matching parentheses, brackets, or braces
{ }Jump backward / forward between paragraphs and blank lines

How do you edit, cut, copy, paste, and undo text in Vim?

Editing in Vim combines verbs (d for delete, c for change, y for yank/copy) with counts and motions to execute atomic edits.

CommandAction
xDelete character under cursor
XDelete character before cursor
ddDelete (cut) current line
5ddDelete 5 consecutive lines
dwDelete word from cursor to next word
d$ or DDelete from cursor to end of line
d0Delete from cursor to start of line
yyYank (copy) current line
5yyYank 5 lines
ywYank word
pPaste copied/cut text after cursor
PPaste copied/cut text before cursor
uUndo last action
Ctrl+rRedo last undone action
.Repeat last editing operation
rReplace single character under cursor
REnter Replace mode (overtype text)
ccChange (delete) line and enter Insert mode
cwChange word from cursor
c$ or CChange from cursor to end of line
~Toggle case of character under cursor
guConvert selection to lowercase (Visual mode)
gUConvert selection to uppercase (Visual mode)
JJoin current line with the line below

How do you perform search, replace, and global matching in Vim?

Search and replace uses the substituted Ex command syntax :%s/pattern/replacement/flags to modify patterns globally or within selected lines.

vim
" Replace all occurrences of 'foo' with 'bar' across entire file
:%s/foo/bar/g

" Replace all occurrences with interactive confirmation prompt
:%s/foo/bar/gc

" Case-insensitive global replace
:%s/foo/bar/gi

" Replace only within lines 10 through 30
:10,30s/foo/bar/g

" Replace only within a visual selection (highlight lines, then type :)
:'<,'>s/foo/bar/g

" Delete all blank lines in file
:g/^$/d

" Delete all lines containing 'TODO'
:g/TODO/d

" Clear current search highlighting
:noh

How do you manage split windows, tabs, marks, and text objects?

Window splitting, tab navigation, marks, and text objects provide high-density workspace controls for editing multiple files.

Split Panes & Tabs

CommandAction
:spHorizontal window split (same file)
:sp file.jsHorizontal split with another file
:vspVertical window split
:vsp file.jsVertical split with another file
Ctrl+w h/j/k/lMove cursor focus between split panes
Ctrl+w =Equalize height and width of all split panes
Ctrl+w _Maximize height of current split pane
Ctrl+w |Maximize width of current split pane
:qClose current split pane
:tabnewOpen new empty tab page
:tabnew file.jsOpen file in a new tab page
gtSwitch to next tab page
gTSwitch to previous tab page
:tabcloseClose current tab page

Marks & Jumps

CommandAction
maSet position mark a at cursor
`aJump to exact line and column of mark a
'aJump to line of mark a
Ctrl+oJump back to previous cursor position
Ctrl+iJump forward to newer cursor position
''Jump back to position before last jump

Text Objects Grammar

Text ObjectTarget ScopeExample Usage
iwInner wordciw (change word under cursor)
awWord + spacedaw (delete word and trailing space)
i"Inside double quotesci" (change text inside "...")
a"Double quotes + contentsda" (delete quotes and contents)
i'Inside single quotesci' (change text inside '...')
i( or ibInside parenthesesci( (change function arguments)
a( or abParentheses + contentsda( (delete function call params)
i{ or iBInside curly bracesci{ (change block body)
itInside HTML/XML tagcit (change inner tag HTML)
ipInner paragraphyip (copy inner paragraph)

How do you use macros to automate repetitive edits?

Macros record a sequence of normal mode keystrokes into a register so they can be replayed across multiple lines.

  1. Position cursor on the line to edit.
  2. Press qa to start recording into register a.
  3. Perform your multi-step edit (e.g. A;<Esc> to add a semicolon).
  4. Press q to stop recording.
  5. Press @a to replay the macro once, or 10@a to replay 10 times.

A clean starter config sets relative line numbers, smart indentation, search highlighting, and system clipboard integration.

vim
" Line numbers
set number
set relativenumber

" Indentation
set tabstop=2
set shiftwidth=2
set expandtab
set autoindent

" Search
set hlsearch
set incsearch
set ignorecase
set smartcase

" UI
set cursorline
set scrolloff=8
set colorcolumn=80
syntax enable

" Mouse support
set mouse=a

" System clipboard & backup
set clipboard=unnamedplus
set noswapfile

Frequently Asked Questions

How do I exit Vim if I am stuck?

Press Esc to return to Normal mode, then type :wq and press Enter to save and quit, or :q! to quit without saving changes. For a dedicated guide, read How to Exit Vim, Vi, and Nano.

What is the main difference between Vim and Neovim?

Neovim is a modernized fork of Vim that introduces Lua for configuration and plugins, built-in Language Server Protocol (LSP) support, asynchronous plugin execution, and improved terminal emulator features.


Share_This Twitter / X
Vishnu
Written By

Vishnu

Founder & Principal Architect at MeshWorld. Senior engineer and instructor specializing in AI agent systems, scalable web architecture, and modern development workflows.

Enjoyed this article?

Support MeshWorld and help us create more technical content