How do I run a normal mode command on every line in a range?
:{range}normal {commands}
The :normal command executes normal mode keystrokes from the command line.
command-line #command-line #ex-commands #editing #normal-mode
:{range}normal {commands}
The :normal command executes normal mode keystrokes from the command line.
command-line #command-line #ex-commands #editing #normal-mode
]]
The ]] motion jumps forward to the next line that starts with { in the first column, which is typically the beginning of a C-style function or section.
/pattern\{-}
The \{-} quantifier in Vim regex matches as few characters as possible, unlike which matches as many as possible (greedy).
]p
The ]p command pastes text and adjusts its indentation to match the current line.
ciw + new text + Esc, then n.
The ciw command followed by new text, combined with and .
ci`
The ` ci ` command changes the text inside backtick delimiters.
<C-w>H
The H command moves the current window to the far left, making it a full-height vertical split.
<C-w>p
The p command jumps to the previously active window (the last window you were in).
<C-w>r
The r command rotates windows in the current row or column.
gt and gT
The gt command moves to the next tab page and gT moves to the previous one.
<C-w>> and <C-w><
The > and > increases width by 1 column > increases width by 10 columns maximizes the window width Example With a vertical split, 20> gives the current window 2
"+y and "+p
The "+ register is linked to the system clipboard.
q{a-z}...q
Recording a macro captures a sequence of keystrokes into a register, which you can replay later.
qa ci"replacement<Esc> /next<CR> q
Macros can contain any Vim command including text objects, searches, and multi-key motions.
"1p through "9p
Registers 1-9 contain the last 9 deletions or changes that are at least one line long.
qa ... j@bj q
You can create macros that call other macros, applying different operations to alternate lines or creating complex editing patterns.
".
The .
"=2+3<CR>p
The expression register = evaluates a Vimscript expression and stores the result.
v
The v command enters character-wise visual mode, letting you select text one character at a time.
y$
The y$ command yanks (copies) text from the cursor position to the end of the line.