How do I filter buffer contents through an external shell command?
The :%!{cmd} command pipes the entire buffer through an external shell command and replaces the buffer contents with the command's output.
category:
command-line
tags:
#editing
#ex-commands
#shell
#filtering
#productivity
How do I edit and reuse previous Ex commands in a full editing buffer?
The command-line window is a special buffer that shows your entire Ex command history and lets you edit entries using the full power of Vim's normal mode before
category:
command-line
tags:
#command-line
#ex-commands
#history
#editing
#productivity
How do I copy a range of lines to another location without yanking and pasting?
The :t command (short for :copy) duplicates lines from one location to another without touching any registers.
category:
command-line
tags:
#editing
#ex-commands
#lines
#productivity
#ranges
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 execute the current line as a shell command and insert the output?
The :.
category:
command-line
tags:
#editing
#ex-commands
#shell
#filtering
#productivity
How do I perform the same operation across multiple files using the argument list?
:args **/*.js | argdo %s/old/new/ge | update
The argument list (arglist) is Vim's mechanism for loading a set of files and running commands across all of them.
category:
command-line
tags:
#command-line
#ex-commands
#arglist
#productivity
#batch
#editing
How do I collect all lines matching a pattern and copy them to the end of the file or a register?
The :g command combined with yank A (uppercase A to append) lets you collect every line matching a pattern into a single register without overwriting previous c
category:
command-line
tags:
#editing
#ex-commands
#global-command
#registers
#filtering
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 save a file I opened without sudo permissions?
The :w !sudo tee % command lets you save a file that requires root permissions, even if you forgot to open Vim with sudo.
category:
command-line
tags:
#command-line
#ex-commands
#editing
How do I insert the contents of another file into the current buffer?
The :r filename command reads the contents of filename and inserts them into the current buffer below the cursor line.
category:
command-line
tags:
#ex-commands
#editing
#buffers
How do I run a shell command from inside Vim?
The :!command syntax lets you execute any shell command directly from within Vim without leaving the editor.
category:
command-line
tags:
#command-line
#ex-commands
#editing
How do I open a terminal inside Vim?
The :terminal command opens an interactive terminal emulator directly inside a Vim window.
category:
command-line
tags:
#command-line
#ex-commands
#buffers-windows
How do I insert the output of a shell command into my file?
The :r !command command executes a shell command and inserts its output directly into the current buffer below the cursor line.
category:
command-line
tags:
#command-line
#ex-commands
#editing
How do I run a normal mode command on every line matching a pattern?
The :g/pattern/normal {commands} command executes normal mode keystrokes on every line in the file that matches the given pattern.
category:
command-line
tags:
#ex-commands
#command-line
#editing
#search
How do I run a command on every line matching a pattern?
The :g/pattern/command (global) command executes an Ex command on every line in the file that matches the given pattern.
category:
command-line
tags:
#ex-commands
#search
#editing
#command-line
How do I delete all blank lines in a file?
The :g/^$/d command deletes every blank line in the file using Vim's powerful global command.
category:
command-line
tags:
#editing
#ex-commands
#search
#formatting
How do I run a search and replace across multiple files?
:cfdo %s/old/new/g | update
The :cfdo %s/old/new/g update command performs a search and replace across every file in the quickfix list and saves each one.
category:
command-line
tags:
#command-line
#ex-commands
#search
#editing
How do I delete all lines matching a pattern?
The :g/pattern/d command deletes every line in the file that matches the given pattern.
category:
command-line
tags:
#search
#ex-commands
#editing
#command-line