How do I search for a pattern only when it's preceded or followed by another pattern?
/\(pattern\)\@<=target or /target\(pattern\)\@=
Vim supports zero-width assertions (lookahead and lookbehind) in its regex engine.
1039 results for "i" a""
/\(pattern\)\@<=target or /target\(pattern\)\@=
Vim supports zero-width assertions (lookahead and lookbehind) in its regex engine.
:cexpr system('grep -rn pattern .')
While :make and :grep populate the quickfix list, they are limited to their configured programs.
iabbrev
:iabbrev defines insert-mode abbreviations that expand automatically when you type a non-keyword character (space, punctuation, ) after the abbreviation.
:g/pattern/yank A
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
command-line #editing #ex-commands #global-command #registers #filtering
q/
How it works Vim keeps a history of all your search patterns.
!{motion}{command}
The ! operator filters the text covered by a motion through an external shell command, replacing the original lines with the command's stdout.
:cexpr system('command')
The :cexpr command parses any expression into the quickfix list using the current errorformat.
:botright split
When you split a window with :split or :vsplit, Vim subdivides only the current window.
buffers-windows #buffers #windows #ex-commands #command-line
:lcd
:cd changes the global working directory, affecting every window and tab in the session.
/\_.pattern
The \.
ddp
The ddp sequence swaps the current line with the line below it.
:TestNearest (vim-test)
vim-test provides commands to run tests from within Vim.
qa f,ldt,F(p q
This macro swaps two comma-separated arguments inside parentheses by cutting the second argument and placing it before the first.
:vsplit
The :vsplit command (or :vs for short) splits the current window vertically, creating a new window side-by-side with the current one.
:earlier 5m
Vim's :earlier and :later commands let you travel through your undo history using time-based offsets — not just individual changes.
"-
Vim silently stores every deletion of less than one line in the special "- register (the "small delete" register).
Use :s/pat/rep/e flag or :silent! prefix
By default, Vim macros abort on the first error — a failed search, a substitute with no matches, or a movement that can't be performed.
:source %
The :source command reads and executes a Vimscript file.
/\cfoo
Vim's \c and \C flags let you force a search to be case-insensitive or case-sensitive on a per-search basis, regardless of your ignorecase and smartcase setting
let @a = 'macro_contents'
Recorded macros are stored in registers, which are lost when you quit Vim (unless viminfo saves them).