How do you record a macro to delete text from cursor to a specific pattern?
qad/pattern\nq
Record a macro that deletes from the cursor to the next match of a pattern using d/pattern.
640 results for "/pattern"
qad/pattern\nq
Record a macro that deletes from the cursor to the next match of a pattern using d/pattern.
qa/pattern\nyy}pq
Record a macro that searches for a pattern, yanks the matching line, goes to the end of the paragraph, and pastes it.
:g/pattern/p
Use :g/pattern/p to print all matching lines.
/\(pattern\)\@<=target or /target\(pattern\)\@=
Vim supports zero-width assertions (lookahead and lookbehind) in its regex engine.
\@<=pattern
The \@<= atom is a positive lookbehind in Vim regex.
:let @/ = 'pattern'
Use :let @/ = 'pattern' to set the search register directly.
/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.
:/pattern/+N and :/pattern/-N
Vim's Ex command ranges can use search patterns as line addresses, and those addresses can include a numeric offset (+N or -N) to target lines relative to the m
:Rg pattern
Use :Rg pattern from fzf.
/pattern/+N or /pattern/-N
Vim's search command accepts an offset that places your cursor on a line relative to the match.
/pattern\@!
The \@! atom is a negative lookahead in Vim regex.
/\v(pattern)@<=match
Vim supports zero-width assertions (lookahead and lookbehind) in its regex engine.
search #search #regex #advanced-search #lookahead #lookbehind
:g/pattern/norm @a
The :g/pattern/norm @a command combines the global command with macro execution.
:vimgrep /pattern/ **/*.ext
The :vimgrep command searches for a pattern across multiple files and populates the quickfix list with the results.
qaq:g/pattern/normal "Ayy
Clear register a with qaq, then use :g/pattern/normal "Ayy to append all matching lines to register a.
\(pattern\)\@=
Vim's regex engine supports zero-width positive lookahead via the \@= operator.
:g/pattern/d
The :g/pattern/d command deletes every line in the file that matches the given pattern.
/pattern\_s\+next
Vim's regular expressions support multi-line matching through underscore-prefixed atoms.
qa/pattern<CR>dd@aq
By starting a macro with a search command, the macro becomes conditional — it jumps to the next match before acting, and terminates when no more matches are f
:filter /pattern/ ls
When you have many open buffers, plain :ls output gets noisy fast.