How do I match a pattern only if it is followed by another pattern?
/pattern\ze followed
The \ze atom marks the end of the match, so you can match a pattern only when it appears before specific text.
142 results for ":marks"
/pattern\ze followed
The \ze atom marks the end of the match, so you can match a pattern only when it appears before specific text.
:filter /pattern/ command
The :filter command restricts the output of another Ex command to only lines matching a given pattern.
/\vfoo\zsbar\zebaz
When you need to target only a slice of a larger pattern, \zs and \ze are usually cleaner than building lookarounds.
cx{motion} … cx{motion} (vim-exchange)
The vim-exchange plugin provides cx{motion} to mark a region, then cx{motion} again on a second region to swap them in place.
:set operatorfunc=MyFunc<CR>g@
Vim lets you define custom operators that behave like built-in ones (d, c, y) — they wait for a motion or text object, then act on the selected region.
:'<,'>!{cmd}
After making a visual selection and entering the command line with :, Vim automatically inserts the range ' for the selection.
:[range]g/pattern/command
The :global command accepts an optional line range prefix that restricts which lines it even considers matching.
\zs and \ze
How it works Vim's \zs (set start) and \ze (set end) atoms let you define which portion of a pattern counts as the actual match, even though the full pattern is
:filter /pattern/ {command}
:filter /pattern/ {command} runs any Ex command but suppresses every output line that does not match the pattern.
:'<,'>s/pattern/replacement/g
When you make a visual selection and then type :, Vim automatically inserts ' as the range — the marks for the start and end of the last visual selection.
:set opfunc and g@
Vim's operatorfunc option lets you define your own operators — just like the built-in d, y, or c — that accept any motion or text object.
]s and [s
How it works When spell checking is enabled in Vim with :set spell, misspelled words are highlighted.
:[range]yank {reg}
Vim's :[range]yank and :[range]delete Ex commands let you capture arbitrary line ranges into a register from the command line, bypassing the need to move the cu
:%s/\zsparseData\ze(/processData/g
Vim's \zs and \ze atoms let you include context in your search pattern without including that context in the replacement.
<C-^>
Pressing (Ctrl-6 on most keyboards) instantly toggles between the current buffer and the alternate file — the last file you were editing.
buffers-windows #navigation #buffers #normal-mode #productivity #windows
:bwipeout
The :bwipeout command (:bw) completely removes a buffer from Vim's memory, including its marks, options, and variables.
:10,20t30
The :t command (short for :copy) duplicates lines from one location to another without touching any registers.
command-line #editing #ex-commands #lines #productivity #ranges
:{start},{end} command
Ex commands accept range specifiers that control which lines are affected.
z=
When spell checking is enabled, the z= command opens a numbered list of spelling suggestions for the misspelled word under the cursor.
editing #editing #spell-check #normal-mode #productivity #prose
:m {line-number}
The :m (move) command moves the current line to after the specified line number.