How do I restrict a search to the current function body?
:[{,]}s/old/new/g
By using the range [{,]}, you can limit a substitute command to the lines between the enclosing braces — effectively the current function or block.
189 results for ""+y"
:[{,]}s/old/new/g
By using the range [{,]}, you can limit a substitute command to the lines between the enclosing braces — effectively the current function or block.
`[ and `]
The ` [ ` and ] ` marks automatically track the boundaries of the last changed or yanked text.
qaYp<C-a>q99@a
By recording a macro that duplicates a line and increments its number, you can generate a numbered list of any length with a single replay command.
macros #macros #editing #normal-mode #automation #productivity
:s/pattern/replace/flags
The substitute command supports several flags that modify its behavior.
<C-x><C-l>
The command triggers whole-line completion in insert mode.
<C-e>
The command scrolls the window down one line at a time while keeping the cursor on its current line (until the cursor would go off-screen).
"ayi(
Combining named registers with text object motions lets you precisely yank structured content — like function arguments, quoted strings, or bracketed expressi
<C-x><C-f>
The command triggers filename completion in insert mode.
editing #editing #insert-mode #completion #file-management #productivity
:TSTextobjectSelect @function.outer
The nvim-treesitter-textobjects plugin provides syntax-aware text objects powered by Treesitter's AST parsing.
"ayv
Using named registers with visual mode lets you store multiple independent snippets simultaneously.
@a (within macro @b)
Vim macros can call other macros, enabling modular macro composition.
g~ap
g~ap is a fast way to invert letter case across a full paragraph without entering Visual mode.
editing #editing #operators #text-objects #case #normal-mode
*NgUgn
gn is often treated as a visual selection command, but it is more powerful when used as a motion target for operators.
d<C-v>2j
Vim lets you override the natural type of any motion by pressing v, V, or between the operator and the motion.
editing #editing #motions #visual-mode #advanced #normal-mode
:set matchpairs+=<:>
By default, the % command jumps between (), {}, and [] pairs.
config #navigation #config #matchpairs #editing #normal-mode
[[ and ]]
[[ and ]] navigate between section boundaries — typically the start of the previous or next top-level block.
cin)
The targets.
:view {file}
:view opens a file with the readonly option set, preventing accidental writes.
:set completeopt=menuone,noinsert,noselect
When completion inserts text too early, you lose control over what gets committed and where undo breakpoints land.
yyp
The yyp command duplicates the current line by yanking it and immediately pasting it below.