How do I browse and manage files using Vim's built-in file explorer?
:Explore / :Vexplore / :Sexplore
Vim ships with netrw, a built-in file explorer that lets you browse directories, open files, create new files, rename, and delete — all without plugins.
category:
buffers-windows
tags:
#navigation
#buffers
#file-management
#netrw
#productivity
How do I re-indent a block of code to match the surrounding indentation?
The = operator performs smart indentation based on Vim's filetype-aware indent rules.
category:
editing
tags:
#editing
#indentation
#text-objects
#formatting
How do I run a substitution without overwriting my current search pattern?
The :keeppatterns modifier runs an Ex command — typically :s, :g, or :v — without modifying @/ (the last search pattern) or the command history.
category:
command-line
tags:
#ex-commands
#search
#substitution
#command-line
#scripting
How do I count how many times a pattern appears in a file without making any changes?
The n flag on the substitute command reports the number of matches without performing any substitution.
category:
search
tags:
#search
#substitute
#ex-commands
#normal-mode
How do I capture shell command output directly into a Vim register?
You can populate any Vim register with the output of an external shell command using :let @{register} = system('{command}').
category:
registers
tags:
#registers
#ex-commands
#shell
How do I search across files and populate the quickfix list without jumping to the first match?
By default, :vimgrep jumps your cursor to the first match it finds, which can be disorienting when you just want to collect results and browse them on your own
category:
search
tags:
#search
#ex-commands
#buffers
How do I count the number of matches for a search pattern?
The :%s/pattern//gn command counts how many times a pattern appears in the file without making any changes.
category:
search
tags:
#search
#ex-commands
#editing
How do I match only part of a search pattern in Vim using \zs and \ze?
Vim's \zs and \ze atoms let you control which part of a matched pattern gets highlighted and operated on.
category:
search
tags:
#search
#regex
#pattern-matching
#substitution
How do I use relative line offsets in Ex commands to target lines near the cursor?
Vim's Ex command addresses support arithmetic offsets relative to the current line (.
category:
command-line
tags:
#ex-commands
#editing
#navigation
#command-line
How do I insert text at the beginning of multiple lines at once using visual block mode?
Visual block mode's I command lets you type once and have the text inserted at the cursor column across all selected lines simultaneously.
category:
visual-mode
tags:
#visual-mode
#editing
#normal-mode
How do I search for a pattern across all files in my project without leaving Vim?
:vimgrep /pattern/ searches recursively through all files in the current working directory tree using Vim's own regex engine, populating the quickfix list with
category:
search
tags:
#search
#quickfix
#ex-commands
#navigation
How do I count the number of pattern matches in a file without making substitutions?
The :s///gn command counts how many times a pattern appears in the file without actually replacing anything.
category:
command-line
tags:
#search
#ex-commands
#substitution
#command-line
How do I jump to any location on screen using a two-character search in Vim?
The vim-sneak plugin by Justin Keyes provides a motion that lets you jump to any visible location by typing just two characters.
category:
plugins
tags:
#plugins
#sneak
#navigation
#motions
#search
How do I match a pattern but only highlight or capture part of it using \zs and \ze?
How it works Vim's \zs (set start) and \ze (set end) atoms let you define which portion of a pattern counts as the actual match, even though the full pattern is
category:
search
tags:
#search
#ex-commands
#normal-mode
How do I pipe a range of lines through an external command and replace them with the output?
The ! operator filters the text covered by a motion through an external shell command, replacing the original lines with the command's stdout.
category:
editing
tags:
#editing
#ex-commands
#normal-mode
#formatting
How do I toggle the case of all characters in a visual selection?
In visual mode, pressing ~ toggles the case of every character in the selection.
category:
visual-mode
tags:
#visual-mode
#editing
How do I go back to a specific point in time using Vim's undo history?
Vim's :earlier and :later commands let you travel through your undo history using time-based offsets — not just individual changes.
category:
editing
tags:
#editing
#undo-redo
#time-travel
#history
How do I list all open buffers in Vim?
The :ls command displays a list of all open buffers in Vim, showing their buffer number, status indicators, file name, and the line the cursor was last on.
category:
buffers-windows
tags:
#buffers
#ex-commands
#navigation
How do I search for an exact multi-word phrase or special text I've selected?
In normal mode, searches for the word under the cursor with word-boundary anchors.
category:
search
tags:
#search
#visual-mode
#navigation
How do I edit a recorded macro without re-recording it from scratch?
When a recorded macro has a typo or needs a small tweak, you don't have to re-record it entirely.
category:
macros
tags:
#macros
#registers
#editing
#command-line