How do I run a macro on every line matching a pattern?
The :global command combined with :normal lets you execute a recorded macro on every line that matches a given pattern.
category:
macros
tags:
#macros
#command-line
#ex-commands
#global
#batch-editing
How do I move all lines matching a pattern to the end of a file?
The :g (global) command combined with :m (move) relocates all matching lines to a specified destination.
category:
command-line
tags:
#command-line
#ex-commands
#global
#editing
#organization
How do I encrypt a file directly in Vim?
The :X command sets an encryption key for the current file.
category:
command-line
tags:
#command-line
#security
#file-management
#ex-commands
How do I add text to the end of every line in a range?
The :normal command executes normal-mode keystrokes on every line in a range.
category:
command-line
tags:
#command-line
#ex-commands
#editing
#normal-mode
#batch-editing
How do I pipe selected text through an external command and replace it?
The ! operator in normal mode pipes text through an external shell command and replaces it with the output.
category:
command-line
tags:
#command-line
#shell
#editing
#filtering
#unix
How do I edit a file on a remote server directly from Vim?
:e scp://user@host//path/to/file
Vim's built-in netrw plugin supports editing files over the network using protocols like SCP, SFTP, and HTTP.
category:
command-line
tags:
#command-line
#netrw
#remote
#file-management
How do I align text into columns using an external command in Vim?
The column -t command formats whitespace-separated text into neatly aligned columns.
category:
command-line
tags:
#command-line
#shell
#formatting
#text-manipulation
How do I automatically open or close the quickfix window based on results?
The :cwindow command intelligently manages the quickfix window — it opens the window only if there are entries in the quickfix list, and closes it if the list
category:
command-line
tags:
#command-line
#quickfix
#workflow
#automation
How do I get a visual tab-completion menu for Vim commands and filenames?
The wildmenu option enhances Vim's command-line completion by showing a horizontal menu of matches above the command line when you press .
category:
config
tags:
#config
#command-line
#completion
#productivity
#vimrc
How do I capture the output of a Vim command into a register or buffer?
:redir @a | {cmd} | redir END
The :redir command redirects the output of Ex commands to a register, file, or variable instead of displaying it on the screen.
category:
command-line
tags:
#command-line
#ex-commands
#registers
#productivity
#advanced
How do I repeat the last Ex command I ran?
The @: command re-executes the most recently run Ex command (any command starting with :).
category:
command-line
tags:
#command-line
#ex-commands
#repeat
#normal-mode
#productivity
How do I send the contents of my buffer to a shell command without replacing the text?
The :w !{cmd} command writes the buffer contents to the stdin of an external shell command without modifying the buffer or saving to disk.
category:
command-line
tags:
#command-line
#ex-commands
#shell
#editing
#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 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 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 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