How do I match a pattern only when it is preceded or followed by another pattern, without including that context in the match?
\@=
Vim's regex engine supports zero-width lookahead and lookbehind assertions using the \@ family of atoms.
\@=
Vim's regex engine supports zero-width lookahead and lookbehind assertions using the \@ family of atoms.
[[
The [[ and ]] commands navigate between top-level code blocks — specifically, lines where { appears in column 1.
:e +{line} {file}
The :edit command accepts a +{cmd} prefix that executes an Ex command immediately after the file is loaded.
command-line #buffers #ex-commands #navigation #command-line
:s/\d\+/\=submatch(0)+1/g
The \= prefix in a :substitute replacement field tells Vim to evaluate the following as a Vimscript expression rather than treating it as a literal string.
:'<,'>s/\%Vpattern/replacement/g
When you press : after making a visual selection, Vim inserts ' to restrict the substitution to the selected lines.
visual-mode #visual-mode #search #editing #ex-commands #normal-mode
/\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
:echo strtrans(@q)
When a macro behaves unexpectedly, :echo strtrans(@q) reveals exactly what is stored in register q—including invisible control characters—as human-readable
:vim /pattern/ **
:vimgrep /pattern/ (shortened to :vim) is Vim's built-in project-wide search.
gq (visual mode)
Pressing gq on a visual selection reformats the selected lines to hard-wrap at textwidth columns.
:let @a = system('cmd')
You can populate any Vim register with the output of an external shell command using :let @{register} = system('{command}').
:let @q='commands'
Macros in Vim are stored in registers as plain text.
:%s/\%Vpattern/replacement/g
The \%V atom restricts a regex match to the last visual selection — more precisely than :'s/.
"%p
Vim has several read-only registers that hold special values.
:e %:r.html
In Vim's command line, % expands to the current buffer's filename.
command-line #ex-commands #command-line #buffers #navigation
]'
The ]' command jumps to the start of the line containing the next lowercase mark in the file, while [' jumps to the previous one.
:lcd
:cd changes the global working directory, affecting every window and tab in the session.
<C-r><C-a>
When you are in command-line mode, inserts the word under the cursor (alphanumeric and _ only).
: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
:match {group} /{pattern}/
:match lets you apply a highlight group to any pattern in the current window without touching the buffer or its syntax rules.
:set nrformats+=alpha
By default, and only increment and decrement numbers (decimal, hex, and octal depending on format).