How do I make word motions like w, b, and e treat hyphens or other characters as part of a word?
:set iskeyword+=-
By default, Vim treats hyphens, dots, and many punctuation characters as word boundaries.
:set iskeyword+=-
By default, Vim treats hyphens, dots, and many punctuation characters as word boundaries.
<C-v>jjlU
Visual block mode lets you select rectangular regions of text, which means you can target a specific column and apply case changes only to that area.
=i{
When editing code with messy indentation — after a paste, a merge conflict, or a refactor — you often need to fix just one block rather than the entire file
:g/pattern/m 0
The :global command combined with :move lets you restructure a file by relocating all lines that match a pattern.
gq
The gq operator reformats text to fit within your configured textwidth.
: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.
gqap
The gq operator reformats text by wrapping lines to fit within the textwidth setting.
v3aw
In visual mode, repeating text object motions progressively expands the selection.
"ayi(
Combining named registers with text object motions lets you precisely yank structured content — like function arguments, quoted strings, or bracketed expressi
:TSTextobjectSelect @function.outer
The nvim-treesitter-textobjects plugin provides syntax-aware text objects powered by Treesitter's AST parsing.
cia (with targets.vim) or daa
While Vim doesn't have a built-in argument text object, the targets.
vaB
The aB text object (around Block) selects everything from the matching { to the closing } — including the braces themselves.
vis
The is (inner sentence) text object selects the sentence the cursor is in — excluding any leading or trailing whitespace that separates sentences.
va"
Vim's text objects let you select structured regions of text with two-keystroke shortcuts.
vas
The vas command visually selects the current sentence, including surrounding whitespace.
cs'"
The vim-surround plugin (by Tim Pope) adds three powerful operators for working with surrounding delimiters — quotes, brackets, parentheses, and HTML tags.
vi<
The vi).
"adiw
The "adiw command deletes the inner word under the cursor and stores it in register a.
ci`
The ` ci ` command changes the text inside backtick delimiters.
cs"' (change), ds" (delete), ys iw" (add)
The vim-surround plugin by Tim Pope adds commands for working with surrounding characters like quotes, brackets, and tags.