How do I limit a search pattern to a specific line range without using :global?
/\%>10l\%<20lTODO
Vim regex supports position atoms that can constrain where a match is allowed to occur.
142 results for ":marks"
/\%>10l\%<20lTODO
Vim regex supports position atoms that can constrain where a match is allowed to occur.
:filter /{pattern}/ history cmd
When command history gets crowded, scanning :history cmd manually is slow.
:let view=winsaveview() | {cmd} | call winrestview(view)
When writing Vimscript functions or mappings, commands like :substitute, gg, or :%normal will move the cursor and change the scroll position.
: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
:'<,'>norm @q
When you visually select lines and then type a : command, Vim automatically inserts ' (the visual range marks) into the command line.
:b N
How it works Every buffer in Vim is assigned a unique number when it is opened.
\%V
The \%V atom in a Vim pattern matches only inside the last visual selection.
search #search #visual-mode #substitute #regex #text-objects
:keepjumps
When writing scripts or running commands that move the cursor (like :g, :s, or :normal), Vim normally adds each cursor position to the jump list.
:g/pattern/.,+2d
Inside a :global command, .
command-line #ex-commands #global #delete #editing #command-line
:set jumpoptions+=stack
By default, Vim's jumplist can feel surprising: if you jump backward and then make a new jump, the old forward path is not always discarded like a browser histo
:g/pattern/+1d
Using :g/pattern/+1d you can delete the line that comes right after each line matching a pattern, in one pass.
:vnew | setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile
For quick throwaway notes, command output cleanup, or temporary edits, a normal buffer is noisy: it appears in :ls, can prompt you to save, and may leave swap a
buffers-windows #buffers-windows #buffers #windows #scratch #workflow
:set winfixwidth
Setting winfixwidth on a window tells Vim not to adjust its width when other windows are created, closed, or resized with =.
/prefix\zsword
Vim's \zs atom marks the start of the match within a longer pattern.
:e!
:e! forces Vim to reload the current file from disk, discarding every unsaved change in the buffer.
buffers-windows #buffers-windows #editing #undo-redo #ex-commands
:keepjumps {cmd}
:keepjumps is a command modifier that suppresses any jump list updates caused by the command that follows it.
8g8
The 8g8 command searches forward from the cursor for the first byte that belongs to an invalid UTF-8 sequence.
:5t.
The :t ex command (also spelled :copy) copies a range of lines to a target address without touching any register.
:set operatorfunc=MyFunc<CR>g@{motion}
Vim's operatorfunc and g@ let you define custom operators that accept any motion or text object, just like built-in operators d, c, and y.
:/pattern1/,/pattern2/
Ex command ranges in Vim are not limited to line numbers and marks — you can use /pattern/ as a range boundary to select lines between any two matching patter