Introduction
Every sysadmin eventually finds themselves SSH’d into a remote server at 2 AM, staring at a configuration file that needs a critical fix. There is no VS Code, no Sublime Text, no graphical environment — just a terminal and whatever editor the system provides. On virtually every Linux and Unix server on the planet, that editor is Vim.
Vim is not just a fallback editor for emergencies. It is a precision instrument for text manipulation that, once mastered, makes you faster at editing configuration files, analyzing logs, performing bulk changes, and automating repetitive tasks. Its modal editing paradigm may feel foreign at first, but it is designed around a fundamental insight: you spend far more time reading and modifying text than typing new text from scratch.
Neovim extends this foundation with modern features — built-in Language Server Protocol (LSP) support, Lua-based configuration, an embedded terminal emulator, and an asynchronous plugin architecture — while maintaining full backward compatibility with Vim. If Vim is a Swiss Army knife, Neovim is the same knife with a few extra tools and a better grip.
This guide covers everything you need to go from zero to productive with Vim and Neovim in a sysadmin context. You will learn the core editing model, essential commands, configuration best practices, and real-world workflows for server administration.
Prerequisites
Before diving in, you should have:
- A Linux or macOS system (or WSL on Windows)
- Basic familiarity with the terminal and shell commands
- SSH access to at least one remote server (for practicing real workflows)
- A willingness to spend the first hour feeling slower than you are with your current editor
That last point is important. Vim has a steep initial learning curve, but the productivity curve inflects sharply upward once the core commands become muscle memory.
Installing Vim and Neovim
Checking for Vim
Vim is pre-installed on most Linux distributions. Verify with:
vim --version | head -1
If you see a version string, you are ready. Most servers ship with vi at minimum, which is often a symlink to vim or a minimal Vi implementation.
Installing Neovim
Neovim is available in the package repositories of all major distributions:
# Debian / Ubuntu
sudo apt update && sudo apt install neovim
# Fedora / RHEL / CentOS (EPEL required on older versions)
sudo dnf install neovim
# Arch Linux
sudo pacman -S neovim
# macOS (via Homebrew)
brew install neovim
# From the official AppImage (any Linux, no root needed)
curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim.appimage
chmod u+x nvim.appimage
./nvim.appimage
Verify the installation:
nvim --version | head -1
Setting Neovim as the Default Editor
To make Neovim your default editor system-wide, add these lines to your ~/.bashrc or ~/.zshrc:
export EDITOR="nvim"
export VISUAL="nvim"
alias vim="nvim"
alias vi="nvim"
Reload your shell configuration:
source ~/.bashrc
Understanding Modal Editing
The single most important concept in Vim is modal editing. Unlike most editors where every keystroke inserts a character, Vim has distinct modes where the same keys perform different actions.
Normal Mode
Normal mode is the default mode and the one you spend the most time in. Keys do not insert characters — they execute commands. Press Escape from any other mode to return here.
In Normal mode:
h,j,k,lmove the cursor left, down, up, and rightdbegins a delete operationybegins a yank (copy) operationppastes text/begins a search
Insert Mode
Insert mode is where you type text. Enter it from Normal mode with any of these keys:
| Key | Action |
|---|---|
i | Insert before cursor |
I | Insert at beginning of line |
a | Append after cursor |
A | Append at end of line |
o | Open new line below |
O | Open new line above |
s | Substitute character (delete and enter Insert) |
S | Substitute entire line |
Press Escape to return to Normal mode. Many experienced users remap Caps Lock to Escape or use jk / jj as an escape sequence to keep hands on the home row.
Visual Mode
Visual mode lets you select text visually, then apply an operation to the selection:
| Key | Action |
|---|---|
v | Character-wise visual selection |
V | Line-wise visual selection |
Ctrl-v | Block (column) visual selection |
After selecting text, apply an operator: d to delete, y to yank, c to change, > to indent, < to unindent, or : to run a command on the selection.
Command-Line Mode
Press : from Normal mode to enter Command-line mode. This is where you run Ex commands:
:w " Save the file
:q " Quit
:wq " Save and quit
:q! " Quit without saving
:e filename " Open a file
:!ls " Run a shell command
:%s/old/new/g " Find and replace across the entire file
Essential Navigation
Efficient navigation is the foundation of Vim productivity. Stop reaching for the arrow keys — the commands below are faster and more composable.
Character-Level Movement
h " Move left
j " Move down
k " Move up
l " Move right
These accept a count prefix: 5j moves down 5 lines, 10l moves 10 characters right.
Word-Level Movement
w " Jump to the start of the next word
W " Jump to the start of the next WORD (space-delimited)
b " Jump backward to the start of the previous word
B " Jump backward to the start of the previous WORD
e " Jump to the end of the current/next word
E " Jump to the end of the current/next WORD
The difference between w and W: lowercase w treats punctuation as word boundaries (e.g., server.conf is three words: server, ., conf), while uppercase W treats only whitespace as boundaries (e.g., server.conf is one WORD).
Line-Level Movement
0 " Jump to the first column of the line
^ " Jump to the first non-blank character
$ " Jump to the end of the line
g_ " Jump to the last non-blank character
Screen-Level Movement
H " Move to the top of the screen (High)
M " Move to the middle of the screen (Middle)
L " Move to the bottom of the screen (Low)
Ctrl-d " Scroll down half a screen
Ctrl-u " Scroll up half a screen
Ctrl-f " Scroll down a full screen (Forward)
Ctrl-b " Scroll up a full screen (Backward)
zz " Center the screen on the cursor
zt " Scroll so the cursor is at the top
zb " Scroll so the cursor is at the bottom
File-Level Movement
gg " Jump to the first line of the file
G " Jump to the last line of the file
42G " Jump to line 42
:42 " Jump to line 42 (Command-line mode)
% " Jump to the matching bracket/parenthesis/brace
Searching Within a File
/pattern " Search forward for pattern
?pattern " Search backward for pattern
n " Jump to the next match
N " Jump to the previous match
* " Search forward for the word under the cursor
# " Search backward for the word under the cursor
Enable incremental search and highlighting so matches appear as you type:
:set incsearch
:set hlsearch
Clear the highlight with :noh or :nohlsearch.
Editing Commands
Vim’s editing commands follow a consistent grammar: operator + motion (or operator + text object). Once you learn the operators and motions separately, you can combine them freely.
Operators
| Operator | Action |
|---|---|
d | Delete |
c | Change (delete and enter Insert mode) |
y | Yank (copy) |
> | Indent right |
< | Indent left |
= | Auto-indent |
gU | Convert to uppercase |
gu | Convert to lowercase |
Combining Operators with Motions
dw " Delete from cursor to the start of the next word
d$ " Delete from cursor to end of line (also D)
d0 " Delete from cursor to start of line
dG " Delete from cursor to end of file
dgg " Delete from cursor to start of file
cw " Change word (delete and enter Insert mode)
c$ " Change to end of line (also C)
cc " Change entire line (also S)
yy " Yank the entire line
y$ " Yank from cursor to end of line
yw " Yank a word
y3w " Yank three words
Put (Paste)
p " Put after the cursor (or below the current line for line-wise yanks)
P " Put before the cursor (or above the current line)
Undo, Redo, and Repeat
u " Undo the last change
Ctrl-r " Redo the last undone change
. " Repeat the last change
The . command is one of Vim’s most powerful features. Perform an edit once — say, ciw"replacement"<Esc> to change a word — then move to the next location and press . to repeat the exact same edit.
Deleting and Changing Characters
x " Delete the character under the cursor
X " Delete the character before the cursor
r " Replace the character under the cursor with the next character typed
R " Enter Replace mode (overwrite characters as you type)
J " Join the current line with the line below
Text Objects
Text objects let you operate on structured units of text regardless of cursor position within them. They follow the pattern i (inner — excludes delimiters) or a (around — includes delimiters).
diw " Delete inner word (the word under the cursor)
daw " Delete a word (including surrounding whitespace)
di" " Delete inside double quotes
da" " Delete around double quotes (includes the quotes)
di( " Delete inside parentheses
da( " Delete around parentheses (includes the parens)
di{ " Delete inside curly braces
da{ " Delete around curly braces
dit " Delete inside an HTML/XML tag
dat " Delete around an HTML/XML tag (includes the tags)
dip " Delete inner paragraph
dap " Delete around a paragraph (includes trailing blank line)
The same text objects work with every operator:
ciw " Change inner word
yi" " Yank inside quotes
va{ " Visually select around braces
>ip " Indent inner paragraph
For sysadmin work, ci" and ci' are particularly useful when editing configuration values enclosed in quotes:
# Cursor anywhere on the IP address:
server_address = "192.168.1.100"
# Type ci" to change the value inside the quotes
Search and Replace
Vim’s search and replace uses the :substitute command (abbreviated :s) and supports regular expressions.
Basic Syntax
:s/old/new/ " Replace first occurrence on current line
:s/old/new/g " Replace all occurrences on current line
:%s/old/new/g " Replace all occurrences in the entire file
:%s/old/new/gc " Replace all with confirmation for each match
:5,20s/old/new/g " Replace all occurrences on lines 5 through 20
:'<,'>s/old/new/g " Replace within visual selection
Using Regular Expressions
Vim uses its own regex flavor. By default, some metacharacters require escaping. Use \v (very magic) to get closer to standard regex:
" Find lines starting with a comment
:%s/^#.*//g
" Find IP addresses (basic pattern)
:%s/\v(\d{1,3}\.){3}\d{1,3}/REDACTED/g
" Find and replace with capture groups
:%s/\v(server_name)\s+(\S+)/\1 newhost.example.com/g
" Using very magic mode for cleaner regex
:%s/\v^(listen\s+)(\d+)/\180/g
Useful Flags
| Flag | Meaning |
|---|---|
g | Global — replace all occurrences on each line |
c | Confirm each replacement |
i | Case-insensitive |
I | Case-sensitive (overrides ignorecase setting) |
n | Count matches without replacing |
e | Suppress errors if no match is found |
Interactive Confirmation
When using the c flag, Vim prompts for each match:
replace with new (y/n/a/q/l/^E/^Y)?
y— replace this matchn— skip this matcha— replace all remaining matchesq— quit substitutionl— replace this match and quit (last)
Working with Multiple Files
Sysadmin work often involves editing several configuration files in a single session. Vim provides three mechanisms for this: buffers, splits, and tabs.
Buffers
A buffer is a file loaded into memory. You can have many buffers open simultaneously:
:e /etc/nginx/nginx.conf " Open a file in a new buffer
:e /etc/hosts " Open another file
:ls " List all open buffers
:bn " Switch to the next buffer
:bp " Switch to the previous buffer
:b3 " Switch to buffer number 3
:bd " Close the current buffer
:bufdo %s/old/new/ge " Run a substitution across all buffers
Splits
Splits let you view multiple buffers on screen simultaneously:
:split filename " Open a horizontal split (also :sp)
:vsplit filename " Open a vertical split (also :vsp)
Ctrl-w h " Move to the left split
Ctrl-w j " Move to the split below
Ctrl-w k " Move to the split above
Ctrl-w l " Move to the right split
Ctrl-w = " Equalize split sizes
Ctrl-w _ " Maximize the height of the current split
Ctrl-w | " Maximize the width of the current split
Ctrl-w o " Close all splits except the current one
:resize 20 " Set horizontal split height to 20 lines
:vertical resize 80 " Set vertical split width to 80 columns
A common workflow: open two related config files side by side to ensure consistency:
vim -O /etc/nginx/sites-available/default /etc/nginx/sites-available/staging
Tabs
Tabs in Vim are not like browser tabs — they are viewports that can each contain their own set of splits:
:tabnew filename " Open a file in a new tab
:tabn " Move to the next tab (also gt)
:tabp " Move to the previous tab (also gT)
:tabclose " Close the current tab
:tabonly " Close all tabs except the current one
Macros and Automation
Macros record a sequence of keystrokes and replay them. They are indispensable for repetitive edits.
Recording a Macro
- Press
qfollowed by a register letter (e.g.,qato record into registera) - Perform the editing actions
- Press
qto stop recording
Replaying a Macro
@a " Play macro stored in register a
@@ " Replay the last executed macro
10@a " Play macro a ten times
Practical Example: Commenting Out Lines
Suppose you need to comment out 20 lines in a configuration file:
qa " Start recording into register a
I#<Esc> " Insert '#' at the beginning of the line
j " Move to the next line
q " Stop recording
19@a " Replay 19 more times
Practical Example: Reformatting a List
You have a list of hostnames, one per line, and need to wrap them in quotes and add a comma:
server1
server2
server3
Record the macro:
qa " Start recording into register a
I"<Esc> " Insert opening quote
A",<Esc> " Append closing quote and comma
j " Move to the next line
q " Stop recording
Then apply to the remaining lines with 2@a (for 2 more lines in this case). The result:
"server1",
"server2",
"server3",
Registers
Registers are Vim’s clipboard system. Every delete, yank, and change stores text in a register.
Named Registers
"ayy " Yank the current line into register a
"ap " Paste from register a
"Ayy " Append the current line to register a (uppercase to append)
Special Registers
| Register | Contents |
|---|---|
"" | Unnamed register (last delete/yank) |
"0 | Last yank |
"1–"9 | Last 9 deletes (most recent first) |
"+ | System clipboard |
"* | Primary selection (Linux X11) |
"% | Current filename |
": | Last command-line command |
". | Last inserted text |
"/ | Last search pattern |
Pasting from the System Clipboard
"+p " Paste from system clipboard in Normal mode
Ctrl-r + " Paste from system clipboard in Insert mode
View the contents of all registers:
:registers
Marks and Jumps
Marks let you bookmark positions within files and jump back to them instantly.
Setting Marks
ma " Set mark 'a' at the current cursor position
mA " Set global mark 'A' (works across files)
Jumping to Marks
'a " Jump to the line of mark a
`a " Jump to the exact position of mark a
'' " Jump to the line of the last jump
`` " Jump to the exact position of the last jump
Special Marks
| Mark | Position |
|---|---|
'. | Last change |
'^ | Last insert |
'[ | Start of last yank/put |
'] | End of last yank/put |
'< | Start of last visual selection |
'> | End of last visual selection |
Jump List
Vim maintains a list of positions you have jumped to. Navigate it with:
Ctrl-o " Jump to the previous position in the jump list
Ctrl-i " Jump to the next position in the jump list
:jumps " View the jump list
This is invaluable when tracing through configuration includes — jump to a referenced file with gf (go to file), examine it, then press Ctrl-o to return.
Essential .vimrc Configuration
A well-configured .vimrc (or ~/.config/nvim/init.vim for Neovim) makes Vim immediately more productive. Below is a practical configuration tuned for sysadmin work.
Minimal Sysadmin .vimrc
" === General Settings ===
set nocompatible " Disable Vi compatibility
filetype plugin indent on " Enable filetype detection
syntax on " Enable syntax highlighting
" === Display ===
set number " Show line numbers
set relativenumber " Show relative line numbers
set cursorline " Highlight the current line
set showmatch " Highlight matching brackets
set scrolloff=8 " Keep 8 lines above/below cursor
set sidescrolloff=8 " Keep 8 columns left/right of cursor
set signcolumn=yes " Always show the sign column
set colorcolumn=80 " Show a marker at column 80
set laststatus=2 " Always show the status line
set showcmd " Show partial commands in the status line
set wildmenu " Enhanced command-line completion
set wildmode=list:longest,full
" === Search ===
set incsearch " Show matches as you type
set hlsearch " Highlight all matches
set ignorecase " Case-insensitive search
set smartcase " Case-sensitive if query has uppercase
" === Indentation ===
set expandtab " Use spaces instead of tabs
set tabstop=4 " Display tabs as 4 spaces
set shiftwidth=4 " Indent by 4 spaces
set softtabstop=4 " Backspace removes 4 spaces
set autoindent " Copy indent from current line
set smartindent " Auto-indent after braces, etc.
" === Behavior ===
set hidden " Allow switching buffers without saving
set mouse=a " Enable mouse support
set clipboard=unnamedplus " Use the system clipboard
set undofile " Persistent undo across sessions
set undodir=~/.vim/undodir " Directory for undo files
set noswapfile " Disable swap files
set nobackup " Disable backup files
set encoding=utf-8 " UTF-8 encoding
set fileencoding=utf-8
set backspace=indent,eol,start " Backspace works as expected
" === Performance ===
set updatetime=300 " Faster CursorHold events
set timeoutlen=500 " Faster key sequence completion
set ttimeoutlen=10 " Faster mode switching
" === Key Mappings ===
let mapleader = " " " Set leader key to space
" Clear search highlighting
nnoremap <leader>h :nohlsearch<CR>
" Quick save and quit
nnoremap <leader>w :w<CR>
nnoremap <leader>q :q<CR>
" Buffer navigation
nnoremap <leader>bn :bnext<CR>
nnoremap <leader>bp :bprevious<CR>
nnoremap <leader>bd :bdelete<CR>
" Split navigation
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" Move lines up and down in Visual mode
vnoremap J :m '>+1<CR>gv=gv
vnoremap K :m '<-2<CR>gv=gv
" Keep cursor centered when scrolling
nnoremap <C-d> <C-d>zz
nnoremap <C-u> <C-u>zz
nnoremap n nzzzv
nnoremap N Nzzzv
" Quick edit common config files
nnoremap <leader>ev :e $MYVIMRC<CR>
nnoremap <leader>sv :source $MYVIMRC<CR>
Create the undo directory:
mkdir -p ~/.vim/undodir
File-Type Specific Settings
Different configuration file types benefit from different indentation settings:
" YAML files (Ansible, Kubernetes, etc.) — 2-space indent
autocmd FileType yaml setlocal tabstop=2 shiftwidth=2 softtabstop=2
" Nginx configuration files
autocmd BufRead,BufNewFile /etc/nginx/* set filetype=nginx
" Shell scripts — tabs
autocmd FileType sh setlocal noexpandtab tabstop=4 shiftwidth=4
" Systemd unit files
autocmd BufRead,BufNewFile *.service set filetype=systemd
Practical Sysadmin Workflows
Editing Nginx Configuration
Open the main Nginx config and the site config side by side:
vim -O /etc/nginx/nginx.conf /etc/nginx/sites-available/default
Common tasks inside the editor:
" Find the server block listening on port 80
/listen 80
" Change the server_name directive
/server_name
ciw server_name newhost.example.com;
" Duplicate a location block
V%y " Select the entire block (V for line-wise, % to matching brace)
p " Paste below
" Comment out an entire location block
V% " Select the block
:s/^/#/ " Prepend '#' to each selected line
Searching and Filtering Logs
Open a large log file in read-only mode:
vim -R /var/log/syslog
Useful commands for log analysis:
" Jump to the end of the file (most recent entries)
G
" Search backward for errors
?error
" Show only lines containing 'failed'
:g/failed/
" Delete all lines NOT containing a pattern (inverse filter)
:v/sshd/d
" Count occurrences
:%s/error//gn
" Extract lines matching a pattern to a new buffer
:redir @a | g/ERROR/ | redir END
:new | put a
Bulk IP Address Replacement
When migrating a server, you often need to update IP addresses across multiple config files:
# Open all config files that reference the old IP
vim $(grep -rl '10.0.1.50' /etc/nginx/ /etc/hosts /etc/network/)
Inside Vim, run the replacement across all open buffers:
:bufdo %s/10\.0\.1\.50/10.0.2.100/ge | update
Breaking this down:
:bufdo— execute the following command in every open buffer%s/10\.0\.1\.50/10.0.2.100/ge— replace old IP with new IP (dots escaped,eflag suppresses “no match” errors)| update— save each buffer only if it was modified
Comparing Configuration Files with vimdiff
vimdiff opens two or more files side by side with differences highlighted:
vimdiff /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak
Navigation within vimdiff:
]c " Jump to the next difference
[c " Jump to the previous difference
do " Obtain the change from the other file (diff obtain)
dp " Put the change into the other file (diff put)
:diffupdate " Re-scan the files for differences
zo " Open a fold
zc " Close a fold
This is essential for reviewing changes before applying them in production.
Editing Remote Files Over SSH
Vim can edit files on remote servers directly using scp:
vim scp://user@server//etc/nginx/nginx.conf
Note the double slash before the absolute path. Neovim also supports this through its built-in netrw plugin.
Sudoedit with Vim
When you open a root-owned file and forget to use sudo:
" Save the file with sudo (Vim)
:w !sudo tee % > /dev/null
" In Neovim, use the suda plugin or this approach:
:w !sudo tee %
A better practice is to use sudoedit from the start:
sudoedit /etc/ssh/sshd_config
This securely copies the file, opens it in your $EDITOR, and writes it back with root privileges.
Neovim-Specific Features
Neovim is a superset of Vim in practice. Everything above works identically. These are the features unique to Neovim.
Built-in LSP Support
Neovim has a native LSP client since version 0.5, enabling IDE-like features (autocompletion, diagnostics, go-to-definition) for configuration languages like YAML, JSON, and Bash:
" In init.vim or init.lua, configure an LSP server:
" Example for bash-language-server
lua << EOF
require'lspconfig'.bashls.setup{}
require'lspconfig'.yamlls.setup{
settings = {
yaml = {
schemas = {
["https://json.schemastore.org/github-workflow.json"] = "/.github/workflows/*",
},
},
},
}
EOF
This gives you real-time validation of your YAML pipelines and shell scripts right in the terminal.
Lua-Based Configuration
Neovim supports init.lua as an alternative to init.vim. Lua is faster and more expressive for complex configurations:
-- ~/.config/nvim/init.lua
-- Basic settings
vim.opt.number = true
vim.opt.relativenumber = true
vim.opt.expandtab = true
vim.opt.tabstop = 4
vim.opt.shiftwidth = 4
vim.opt.ignorecase = true
vim.opt.smartcase = true
vim.opt.hlsearch = true
vim.opt.incsearch = true
vim.opt.scrolloff = 8
vim.opt.signcolumn = "yes"
vim.opt.updatetime = 300
vim.opt.undofile = true
vim.opt.clipboard = "unnamedplus"
-- Leader key
vim.g.mapleader = " "
-- Keymaps
local keymap = vim.keymap.set
keymap("n", "<leader>h", ":nohlsearch<CR>")
keymap("n", "<leader>w", ":w<CR>")
keymap("n", "<leader>q", ":q<CR>")
keymap("n", "<C-h>", "<C-w>h")
keymap("n", "<C-j>", "<C-w>j")
keymap("n", "<C-k>", "<C-w>k")
keymap("n", "<C-l>", "<C-w>l")
Embedded Terminal
Neovim includes a full terminal emulator. This lets you run shell commands without leaving the editor:
:terminal " Open a terminal in the current window
:split | terminal " Open a terminal in a horizontal split
:vsplit | terminal " Open a terminal in a vertical split
Inside the terminal:
- You are in Terminal mode (a Neovim-specific mode)
- Press
Ctrl-\ Ctrl-nto switch to Normal mode (so you can scroll, search, and yank output) - Press
iorato switch back to Terminal mode
This is powerful for workflows like tailing a log file in one split while editing the relevant configuration in another.
Checkhealth
Neovim provides a diagnostic tool to verify your setup:
:checkhealth
This reports the status of providers (Python, Node.js, clipboard), LSP servers, and plugins. Run it after any major configuration change.
Vim Cheat Sheet
Quick Reference: Modes
| Key | Mode | Purpose |
|---|---|---|
Escape | Normal | Navigation and commands |
i / a | Insert | Typing text |
v / V / Ctrl-v | Visual | Selecting text |
: | Command-line | Running Ex commands |
R | Replace | Overwriting text |
Quick Reference: Navigation
| Command | Action |
|---|---|
h j k l | Left, down, up, right |
w / b / e | Next word / previous word / end of word |
0 / $ / ^ | Start of line / end / first non-blank |
gg / G | Start / end of file |
Ctrl-d / Ctrl-u | Scroll half-page down / up |
% | Matching bracket |
/ / ? | Search forward / backward |
n / N | Next / previous search match |
* / # | Search word under cursor forward / backward |
Quick Reference: Editing
| Command | Action |
|---|---|
x | Delete character |
dd | Delete line |
dw | Delete word |
D | Delete to end of line |
cc | Change line |
cw | Change word |
C | Change to end of line |
yy | Yank line |
yw | Yank word |
p / P | Paste after / before |
u / Ctrl-r | Undo / redo |
. | Repeat last change |
>> / << | Indent / unindent line |
Quick Reference: Text Objects
| Command | Scope |
|---|---|
iw / aw | Inner / around word |
is / as | Inner / around sentence |
ip / ap | Inner / around paragraph |
i" / a" | Inner / around double quotes |
i' / a' | Inner / around single quotes |
i( / a( | Inner / around parentheses |
i{ / a{ | Inner / around curly braces |
i[ / a[ | Inner / around square brackets |
it / at | Inner / around HTML/XML tags |
Quick Reference: Files and Buffers
| Command | Action |
|---|---|
:w | Save |
:q | Quit |
:wq / ZZ | Save and quit |
:q! / ZQ | Quit without saving |
:e file | Open file |
:bn / :bp | Next / previous buffer |
:ls | List buffers |
:sp / :vsp | Horizontal / vertical split |
Ctrl-w + h/j/k/l | Navigate splits |
:tabnew | New tab |
gt / gT | Next / previous tab |
Quick Reference: Search and Replace
| Command | Action |
|---|---|
:%s/old/new/g | Replace all in file |
:%s/old/new/gc | Replace all with confirmation |
:s/old/new/g | Replace all on current line |
:5,20s/old/new/g | Replace on lines 5–20 |
:%s/old/new/gi | Case-insensitive replace |
Quick Reference: Macros and Registers
| Command | Action |
|---|---|
qa | Start recording macro into register a |
q | Stop recording |
@a | Play macro a |
@@ | Replay last macro |
"ay | Yank into register a |
"ap | Paste from register a |
"+y / "+p | Yank / paste system clipboard |
:registers | View all registers |
Next Steps
This guide covers the essential toolkit. To continue building your Vim proficiency:
-
Run
vimtutor— Vim ships with an interactive tutorial. Launch it from your terminal withvimtutorand work through it in 30 minutes. -
Practice daily — Use Vim for all your configuration editing for at least two weeks before evaluating whether it works for you. The initial slowdown is temporary.
-
Learn incrementally — Do not try to memorize every command at once. Pick two or three new commands per week and incorporate them into your workflow.
-
Explore plugins — Once comfortable with core Vim, consider plugins like
telescope.nvim(fuzzy finder),nvim-treesitter(better syntax highlighting), orwhich-key.nvim(keybinding hints) for Neovim. -
Read
:help— Vim’s built-in documentation is exceptionally thorough. Type:helpfollowed by any command or topic to access it.
The investment in learning Vim pays compound interest. Every configuration file you edit, every log you search, and every bulk change you make across a fleet of servers becomes faster and more precise. The editor that initially felt hostile becomes the one you reach for first.