How do I restrict the :global command to operate on only a portion of the file?
:[range]g/pattern/command
The :global command accepts an optional line range prefix that restricts which lines it even considers matching.
2125 results for "i" a""
:[range]g/pattern/command
The :global command accepts an optional line range prefix that restricts which lines it even considers matching.
:/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
luaeval('lua_expression')
When you have existing Vimscript code that needs to reach into Neovim's Lua ecosystem, luaeval() is the bridge.
<C-w>TgT
When a split temporarily becomes the center of attention, promoting it to its own tab can reduce layout noise.
:[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
getbufline() / setbufline()
The getbufline() and setbufline() functions let you inspect and update any loaded buffer's contents from Vimscript without switching the active window.
:{range} normal @{reg}
The :normal command lets you execute Normal mode keystrokes over a range of lines.
10@a
The 10@a command replays the macro recorded in register a exactly 10 times.
dp
In Vim's diff mode, dp (diff put) and do (diff obtain) are single-keystroke shorthands for :diffput and :diffget.
buffers-windows #diff #buffers-windows #editing #normal-mode
/pattern\{3}
Vim supports counted quantifiers that let you specify exactly how many times a pattern should repeat.
:w ++p
Neovim's :w ++p flag automatically creates any missing intermediate directories when writing a file.
:<C-r>a
How it works While typing an Ex command on the command line (after pressing :), you can insert the contents of any register by pressing Ctrl-R followed by the r
\@=
Vim's regex engine supports zero-width lookahead and lookbehind assertions using the \@ family of atoms.
:echohl WarningMsg | echo "message" | echohl None
:echohl sets the highlight group applied to subsequent :echo and :echom output.
:g/^\s*$/d
The global command :g/^\s$/d removes every line that is empty or contains only whitespace — a common cleanup task when tidying up code, configuration files, o
:move +1 / :move -2
The :move command relocates lines to a specific position without using delete and paste.
:oldfiles
:oldfiles displays a numbered list of every file Vim has recorded in its viminfo (or shada in Neovim) file.
set nrformats-=octal
By default, Vim treats numbers prefixed with a leading zero (like 007) as octal when you use or to increment or decrement them.
\@>
Vim's \@> syntax creates an atomic group in a regular expression.
cgn...{text}<Esc>.
The cgn + .