How do I enter a mode where I select text and then typing immediately replaces the selection, like in most graphical editors?
Vim's Select mode behaves like the familiar selection model in most GUI editors: after selecting text, any printable character you type replaces the selection a
category:
visual-mode
tags:
#visual-mode
#select-mode
#editing
#normal-mode
How do I move the current line or a visual selection up or down without cutting and pasting?
The [e and ]e mappings from Tim Pope's vim-unimpaired plugin exchange the current line (or a visual selection of lines) with the line above or below.
category:
plugins
tags:
#plugins
#editing
#motions
How do I run a recorded macro on every quickfix match without touching unrelated lines?
When a refactor target spans many files but only specific matches matter, running a macro globally is risky.
category:
macros
tags:
#macros
#quickfix
#automation
#ex-commands
How do I edit the contents of a macro using Vimscript string functions without re-recording it?
:let @q = substitute(@q, 'from', 'to', 'g')
Macros are stored as plain text in named registers, so you can manipulate them with any Vimscript string function.
category:
macros
tags:
#macros
#registers
#ex-commands
How do I load multiple files matching a pattern into Vim for batch editing?
The :args command populates Vim's argument list with files matching a glob pattern, turning any set of files into a navigable list and enabling project-wide bat
category:
buffers-windows
tags:
#buffers
#ex-commands
#editing
#navigation
How do I open a new line below the cursor and start typing?
The o command opens a new line below the current line and places you in insert mode, ready to type.
category:
editing
tags:
#editing
#insert-mode
#normal-mode
How do I add a visual indicator at the start of soft-wrapped continuation lines to tell them apart from real line starts?
When wrap is enabled, long lines visually wrap to the next screen row.
category:
config
tags:
#config
#display
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 manually save the undo history for a file to a separate undo file in Vim?
The :wundo {file} command writes the current buffer's entire undo history to a file on disk.
category:
command-line
tags:
#undo-redo
#command-line
#editing
How do I use glob() in Vimscript to get a list of files matching a wildcard pattern?
The glob() built-in function expands a wildcard pattern into a list of matching filesystem paths, entirely within Vimscript.
category:
config
tags:
#config
#vimscript
#files
#ex-commands
How do I paste the contents of a register as a new line below the cursor regardless of the register type in Vim?
The :put Ex command always inserts a register's content as a new line below the current line, regardless of whether the register holds characterwise, linewise,
category:
editing
tags:
#registers
#editing
#paste
#ex-commands
#normal-mode
How do I search across all Vim help files for a keyword or phrase?
:helpgrep {pattern} searches all installed Vim help files for a pattern and populates the quickfix list with every match.
category:
command-line
tags:
#ex-commands
#command-line
#search
How do I save and restore the current window layout after temporarily changing window sizes in a Vim script?
The winrestcmd() function returns a string of Ex commands that, when executed, restore all window sizes to their state at the time of the call.
category:
config
tags:
#config
#vimscript
#windows
How do I open an existing buffer in a new tab page in Vim?
How it works The :tab sb N command opens buffer number N in a brand new tab page.
category:
buffers-windows
tags:
#buffers
#tabs
#ex-commands
#navigation
How do I run a normal mode command from the ex command line without triggering my custom key mappings?
:normal {command} runs a sequence of Normal mode keystrokes from the command line (or a range of lines with :%normal), but it applies your custom key mappings.
category:
command-line
tags:
#ex-commands
#macros
#normal-mode
#command-line
How do I open a file by name without knowing its full path?
The :find command searches for a file by name across all directories listed in Vim's path option, so you can open files without typing full paths.
category:
navigation
tags:
#navigation
#ex-commands
#buffers
#editing
How do I run a command on lines matching a pattern within blocks matching another pattern?
The :global command accepts a range, which lets you scope its search to sections of the file rather than the entire buffer.
category:
command-line
tags:
#ex-commands
#search
#editing
#normal-mode
How do I jump between merge conflict markers in a file?
During a git merge, Vim can navigate directly between conflict markers (>>>>>>) using ]n and [n.
category:
navigation
tags:
#navigation
#diff
#merge
#conflicts
How do I search only files in the argument list and inspect results in a location list?
:lvimgrep /{pattern}/j ## | lopen
When you need to run focused searches across a curated set of files, the argument list is a strong scope boundary.
category:
search
tags:
#search
#ex-commands
#location-list
#workflow
How do I define a mapping that only takes effect if the key is not already mapped?
:map <unique> {key} {rhs}
The modifier causes Vim to fail with an error if you try to create a mapping for a key that is already mapped in that mode.
category:
config
tags:
#config
#ex-commands