How do I create a custom operator that works with motions and text objects?
:set operatorfunc=MyFunc<CR>g@
Vim lets you define custom operators that behave like built-in ones (d, c, y) — they wait for a motion or text object, then act on the selected region.
category:
config
tags:
#config
#normal-mode
#motions
#text-objects
#mapping
How do I delete through the end of the next search match from the cursor?
When you need to remove text up to a known marker, a plain search motion is often almost right but stops at the start of the match.
category:
navigation
tags:
#navigation
#search
#motions
#editing
How do I select text character by character in Vim?
The v command enters character-wise visual mode, letting you select text one character at a time.
category:
visual-mode
tags:
#visual-mode
#normal-mode
How do I copy the entire current line to the system clipboard?
The "+yy command yanks the current line directly to the system clipboard register, making it available for pasting in other applications.
category:
registers
tags:
#registers
#editing
How do I delete text from the cursor to the next occurrence of a pattern?
Vim lets you use a / search as a motion for any operator.
category:
editing
tags:
#editing
#search
#motions
#delete
#normal-mode
How do I change surrounding quotes or brackets from one type to another with vim-surround?
The vim-surround plugin (by Tim Pope) adds three powerful operators for working with surrounding delimiters — quotes, brackets, parentheses, and HTML tags.
category:
plugins
tags:
#plugins
#text-objects
#editing
How do I select an entire code block from opening brace to closing brace in visual mode?
Pressing V% enters visual line mode on the current line and immediately extends the selection to the line containing the matching bracket or brace.
category:
visual-mode
tags:
#visual-mode
#navigation
#text-objects
#motions
How do I append text to the end of multiple lines that have different lengths?
Visual block mode normally selects a fixed-width column, which makes appending tricky when lines have different lengths.
category:
visual-mode
tags:
#visual-mode
#editing
#insert-mode
How do I check whether a register contains characterwise, linewise, or blockwise text?
The getregtype() function returns the motion type of a register's content — whether it was yanked characterwise, linewise, or as a visual block.
category:
registers
tags:
#registers
#ex-commands
#macros
How do I recover text from older deletions using Vim's numbered registers?
Vim automatically stores your deletion history in numbered registers "1 through "9.
category:
registers
tags:
#registers
#editing
#normal-mode
#undo-redo
How do I visually select the next occurrence of my last search pattern?
The gn motion searches forward for the next match of the last search pattern and visually selects it.
category:
search
tags:
#navigation
#search
#motions
#normal-mode
#repeat
#editing
How do I enter a mode where I select text and then typing immediately replaces the selection, like in most graphical editors?
Vim's Select mode behaves like the familiar selection model in most GUI editors: after selecting text, any printable character you type replaces the selection a
category:
visual-mode
tags:
#visual-mode
#select-mode
#editing
#normal-mode
How do I invert the case of an entire paragraph with one operator command?
g~ap is a fast way to invert letter case across a full paragraph without entering Visual mode.
category:
editing
tags:
#editing
#operators
#text-objects
#case
#normal-mode
How do I incrementally expand or shrink a selection based on syntax tree nodes using nvim-treesitter?
nvim-treesitter's incremental selection module lets you grow and shrink your visual selection one syntax node at a time.
category:
plugins
tags:
#visual-mode
#plugins
#text-objects
#editing
How do I visually select from the cursor to the matching bracket or parenthesis?
How it works The % motion jumps to the matching bracket, parenthesis, or brace.
category:
visual-mode
tags:
#visual-mode
#navigation
#motions
#editing
How do I visually select an entire code block to the matching closing brace?
Pressing V]} in normal mode enters visual line mode and immediately extends the selection to the next unmatched closing brace }.
category:
visual-mode
tags:
#visual-mode
#navigation
#text-objects
#editing
#motions
How do I use gn as a text object to delete or yank the next search match?
The gn motion is a versatile text object that selects the next occurrence of the last search pattern.
category:
editing
tags:
#editing
#search
#text-objects
#normal-mode
#motions
What is the difference between the inner word (iw) and inner WORD (iW) text objects in Vim?
Vim has two flavors of the "inner word" text object that are easy to confuse: iw (lowercase) and iW (uppercase).
category:
editing
tags:
#text-objects
#editing
#motions
#normal-mode
How do I set a bookmark that persists across different files and Vim sessions?
Vim has two tiers of marks.
category:
navigation
tags:
#marks
#navigation
#normal-mode
How do I delete, change, or yank an entire sentence as a text object in Vim?
Vim defines a sentence as text ending with .
category:
editing
tags:
#editing
#text-objects
#delete
#normal-mode
#motions