How do I delete all lines that do NOT match a pattern?
The :v command (short for :vglobal) is the inverse of :g — it executes a command on every line that does not match the given pattern.
category:
command-line
tags:
#editing
#ex-commands
#search
#filtering
#productivity
How do I run Normal mode commands in a script without triggering my custom mappings?
:normal {keys} executes keystrokes as if typed in Normal mode — but it respects your custom mappings and abbreviations.
category:
macros
tags:
#macros
#ex-commands
#normal-mode
How do I send Telescope results to the quickfix list for bulk editing?
While inside any Telescope picker, pressing sends all current results to the quickfix list and closes the picker.
category:
plugins
tags:
#plugins
#search
#quickfix
#buffers-windows
How do I insert the entire current line into the command line without typing it?
Pressing on the command line inserts the full text of the current buffer line (the line the cursor is on when you pressed :) directly at the command-line cursor
category:
command-line
tags:
#command-line
#editing
#navigation
How do I split a complex Vim macro into reusable subroutines?
Record worker macro in @b, call it from @a with @b
Complex macros are hard to debug and maintain when crammed into a single register.
category:
macros
tags:
#macros
#registers
#editing
How do I specify line ranges in Ex commands to target specific parts of a file?
Every Ex command in Vim can be preceded by a range that specifies which lines it should operate on.
category:
command-line
tags:
#command-line
#ex-commands
#ranges
#editing
#productivity
How do I jump back and forth between my two most recent cursor positions?
Vim maintains a jumplist — a history of every "jump" you make (searches, marks, gg, G, %, etc.
category:
navigation
tags:
#navigation
#jumplist
#motions
#workflow
How do I apply a normal mode command to every line in a range at once?
:normal (abbreviated :norm) executes a sequence of normal-mode keystrokes on each line of an address range.
category:
command-line
tags:
#ex-commands
#editing
#normal-mode
#macros
How do I write a Vim plugin using the autoload directory structure?
The autoload mechanism in Vim lets you write plugins whose functions are only loaded into memory when they are first called.
category:
plugins
tags:
#plugins
#ex-commands
#editing
What is the difference between :norm and :norm! when running normal commands from the command line?
Both :norm and :norm! execute a sequence of Normal mode keystrokes from the command line or a script, but they differ in how they handle user-defined mappings.
category:
command-line
tags:
#ex-commands
#normal-mode
#macros
#vimscript
How do I edit a complex Ex command in a full editing window?
q: or <C-f> from : prompt
The command-line window (q:) opens a full Vim buffer containing your Ex command history.
category:
command-line
tags:
#command-line
#history
#editing
#workflow
How do I jump to a tag in Vim and automatically choose if there is only one match?
Vim's :tjump is the smarter sibling of :tag and :tselect.
category:
navigation
tags:
#navigation
#tags
#ctags
#search
How do you create a numbered sequence using visual block mode?
Select a column of identical numbers with , then press g to create an incrementing sequence (1,2,3.
category:
visual-mode
tags:
#visual
#block
#sequence
How do I center or right-align text to a specific width in Vim?
Vim has built-in text alignment commands that adjust lines relative to a specified width.
category:
editing
tags:
#editing
#alignment
#formatting
#text
How do I paste the last Ex command I ran into my buffer?
The : register holds the most recently executed Ex command.
category:
registers
tags:
#registers
#ex-commands
#normal-mode
#productivity
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 search for text only within a visual selection?
The \%V atom restricts a search pattern to only match inside the most recent visual selection.
category:
search
tags:
#search
#visual-mode
#regex
#substitution
#advanced
How do I jump forward through the jump list after going back with Ctrl-O?
Every time you make a "jump" — using G, /, %, :tag, , or similar commands — Vim records your position in the jump list.
category:
navigation
tags:
#navigation
#normal-mode
How do you use a macro to prepend line numbers to each line?
Start at line 1, record a macro that inserts 1.
category:
macros
tags:
#macros
#line-numbers
#prepend
How do I insert the same text at the start (or end) of multiple lines simultaneously?
<C-v>{motion}I{text}<Esc>
Visual block mode () lets you select a rectangular region across multiple lines.
category:
visual-mode
tags:
#visual-mode
#editing
#normal-mode