How do I prevent Vim from pausing at the --More-- prompt when displaying long command output?
When a Vim command produces output that exceeds the terminal height, Vim pauses and displays a -- More -- prompt, requiring you to press a key to continue.
category:
config
tags:
#config
#command-line
#ex-commands
How do I duplicate the current line to the end of the file without yanking or moving the cursor?
The Ex command :.
category:
editing
tags:
#editing
#ex-commands
#copy
#ranges
How do I reuse the replacement text from my last substitution in a new one without retyping it?
In a Vim substitution, using ~ as the replacement string repeats the replacement text from the most recent :s command.
category:
search
tags:
#search
#substitution
#ex-commands
#editing
How do I run a command without triggering any autocommands, such as saving without auto-formatting?
The :noautocmd (abbreviated :noa) prefix suppresses all autocommand events for the duration of the command that follows it.
category:
command-line
tags:
#ex-commands
#config
#editing
How do I undo or redo to a specific point in time using time-based undo navigation?
:earlier {time} and :later {time}
Vim's :earlier and :later commands let you navigate the undo history by elapsed time rather than by edit count.
category:
command-line
tags:
#undo-redo
#ex-commands
#editing
How do I read or modify the lines of a buffer that is not currently displayed without switching to it?
getbufline() / setbufline()
The getbufline() and setbufline() functions let you inspect and update any loaded buffer's contents from Vimscript without switching the active window.
category:
buffers-windows
tags:
#buffers-windows
#ex-commands
How do I access event-specific data like yank contents or inserted characters inside a Vim autocommand?
The v:event dictionary is populated inside certain autocommand callbacks with data specific to that event.
category:
config
tags:
#config
#ex-commands
#registers
How do I scope a Vimscript variable to a specific buffer, window, tab, or script to avoid conflicts?
Vimscript variables are prefixed with a one-letter scope identifier followed by a colon.
category:
config
tags:
#config
#ex-commands
How do I zero-pad or reformat numbers during a substitution using printf in Vim?
:%s/\d\+/\=printf('%03d', submatch(0))/g
Combining Vim's \= expression substitution with the printf() function lets you apply arbitrary formatting to matched text.
category:
search
tags:
#search
#substitution
#ex-commands
#editing
How do I send a visual selection to an external command as input without replacing the selected text?
The :'w !{cmd} command writes the visually selected lines to the stdin of an external shell command — without modifying the buffer.
category:
visual-mode
tags:
#visual-mode
#ex-commands
#editing
#normal-mode
How do I save a file with specific line endings in one command without changing the buffer's fileformat setting?
The ++ff modifier on :w forces the file format used for writing, independently of the buffer's 'fileformat' option.
category:
command-line
tags:
#ex-commands
#formatting
#command-line
#editing
How do I clear all entries from the quickfix list in Vim?
After a :grep, :make, or :vimgrep run, the quickfix list fills with results.
category:
command-line
tags:
#command-line
#buffers-windows
#quickfix
#ex-commands
How do I insert all Vim messages into the current buffer so I can read, search, or save them?
:put =execute('messages')
Vim's :messages command shows recent output — error messages, echo'd values, and diagnostic information — but the display is ephemeral and hard to search.
category:
registers
tags:
#registers
#ex-commands
#debugging
#command-line
How do I replace only the current match and then stop when doing an interactive substitution in Vim?
l (in :%s///gc confirm prompt)
When running an interactive substitution with the c flag (e.
category:
editing
tags:
#search
#editing
#substitution
#ex-commands
#normal-mode
How do I format and pretty-print JSON in the current Vim buffer using Python?
When editing JSON files in Vim, you can pipe the entire buffer through Python's built-in json.
category:
editing
tags:
#editing
#formatting
#ex-commands
#json
#shell
How do I refer to all files in the argument list at once in an Ex command?
The ## special token expands to the names of all files currently in Vim's argument list.
category:
command-line
tags:
#command-line
#buffers
#ex-commands
#search
How do I save just the visually selected lines to a new file?
After making a visual selection, you can write only those lines to a new file using :'w {filename}.
category:
visual-mode
tags:
#visual-mode
#editing
#ex-commands
How do I sort lines in Vim without caring about upper or lower case?
By default, :sort uses byte-value ordering, which places all uppercase letters before lowercase.
category:
command-line
tags:
#editing
#ex-commands
#command-line
How do I sort lines while ignoring a leading prefix like a key or label?
The :sort /{pattern}/ command sorts lines by their content after the first match of the pattern.
category:
command-line
tags:
#editing
#ex-commands
#command-line
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