How do I use search patterns as line ranges in Ex commands to operate on a block of text?
Instead of specifying line numbers for Ex command ranges, you can use search patterns.
category:
command-line
tags:
#ex-commands
#editing
#search
#ranges
#command-line
How do I align columns of text into a neatly formatted table in Vim?
When working with data that has uneven spacing — such as variable assignments, CSV-like data, or configuration entries — you can select the lines and pipe t
category:
visual-mode
tags:
#visual-mode
#editing
#formatting
#external-command
#alignment
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 run an Ex command without changing the current search pattern?
Many Ex commands silently overwrite the search register (@/), which changes your hlsearch highlighting and n/N behavior.
category:
command-line
tags:
#ex-commands
#search
#command-line
How do I jump to the enclosing curly brace or parenthesis in code?
When editing code inside a deeply nested block, [{ jumps backward to the unmatched { that encloses the current position, and ]} jumps forward to its matching }.
category:
navigation
tags:
#navigation
#motions
#editing
#normal-mode
How do I copy a character from the line above or below while in insert mode?
When typing in insert mode, you can pull individual characters from adjacent lines without leaving insert mode.
category:
editing
tags:
#insert-mode
#editing
#completion
How do I paste a register in insert mode without triggering auto-indent?
When you use a in insert mode to paste register a, Vim inserts the text as if you typed it character by character.
category:
registers
tags:
#registers
#insert-mode
#indentation
#editing
How do I switch between character, line, and block visual selection without reselecting?
v / V / <C-v> (while in visual mode)
When you are already in visual mode and realize you need a different selection type, you do not have to exit and re-enter.
category:
visual-mode
tags:
#visual-mode
#editing
#normal-mode
How do I edit a recorded macro by modifying it as text in a buffer?
Recorded macros are stored as plain text in registers, but editing them by re-recording is tedious for complex sequences.
category:
macros
tags:
#macros
#registers
#editing
How do I selectively merge changes between two files in Vim's diff mode?
When comparing two files side by side with :diffsplit or vim -d, you often want to pull specific changes from one file into another rather than accepting all di
category:
buffers-windows
tags:
#buffers
#windows
#editing
#ex-commands
How do I combine multiple Ex commands into a single undo step in Vim?
When writing Vim scripts or running multiple Ex commands, each command normally creates a separate undo entry.
category:
command-line
tags:
#undo-redo
#ex-commands
#editing
How do I search for a pattern in the current file and navigate results with the quickfix list?
When you need to find all occurrences of a pattern in the current file and jump between them systematically, :vimgrep with % is more powerful than basic / searc
category:
search
tags:
#search
#quickfix
#ex-commands
#navigation
How do I increase or decrease indentation while staying in insert mode?
<C-t> and <C-d> in insert mode
When typing in insert mode, you can adjust the current line's indentation without leaving to normal mode.
category:
editing
tags:
#insert-mode
#indentation
#editing
#formatting
How do I quickly jump between method or function definitions in code?
The ]m and [m motions let you jump forward and backward between the start of method or function definitions.
category:
navigation
tags:
#navigation
#motions
#normal-mode
#editing
How do I create a recursive macro that repeats itself until it fails?
A recursive macro calls itself at the end of its sequence, creating a loop that automatically repeats until a motion or command fails (such as hitting the last
category:
macros
tags:
#macros
#editing
#normal-mode
#registers
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 reverse the order of all lines in a file using Vim?
This clever use of the :global command reverses every line in the current buffer.
category:
command-line
tags:
#editing
#ex-commands
#global
#text-manipulation
How do I open a terminal in the current window instead of a new split?
By default, :terminal opens a new split window for the terminal emulator.
category:
buffers-windows
tags:
#terminal
#buffers
#windows
#shell
#ex-commands
How do I set different Vim options for specific programming languages?
autocmd FileType python setlocal ts=4 sw=4 et
Using autocmd FileType, you can configure Vim to automatically apply buffer-local settings whenever a file of a particular type is opened.
category:
config
tags:
#config
#ex-commands
#editing
#formatting
How do I transfer diff hunks between files in Vim's diff mode?
When comparing two files side by side in Vim's diff mode (:diffsplit or vim -d file1 file2), you often want to accept or push individual changes between the fil
category:
navigation
tags:
#navigation
#editing
#buffers
#windows