How do I move all lines matching a pattern to the top of the file?
When working with large files, you sometimes need to reorganize content by pulling all lines matching a certain pattern to the top.
category:
command-line
tags:
#global
#move
#ex-commands
#editing
#command-line
How do I run a command on lines near each match, not just the matching line itself?
The :g (global) command normally operates on lines that match a pattern.
category:
command-line
tags:
#ex-commands
#editing
#search
#global
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 run normal mode edits on every line matching a pattern?
The :global command combined with :normal lets you execute arbitrary normal mode keystrokes on every line that matches a pattern.
category:
command-line
tags:
#global
#normal-mode
#editing
#ex-commands
#batch-editing
How do I move all lines matching a pattern to the end of the file in Vim?
The :g (global) command combined with :m (move) lets you collect all lines matching a pattern and relocate them to a specific position in the file.
category:
command-line
tags:
#ex-commands
#editing
#global
#search
#formatting
How do I chain multiple commands on lines matching a pattern with :g?
The :g (global) command can execute multiple Ex commands per matching line by chaining them with .
category:
command-line
tags:
#command-line
#global
#ex-commands
#batch-editing
#advanced
How do I collect all lines matching a pattern into a register?
The :g/pattern/y A command yanks every line matching the pattern and appends it to register a.
category:
command-line
tags:
#command-line
#registers
#global
#ex-commands
#filtering
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