Learn Vim Grammar: Delete, Change, Yank & Text Objects | Episode 2
Video: Learn Vim Grammar: Delete, Change, Yank & Text Objects | Episode 2 by Taught by Celeste AI - AI Coding Coach
Watch full page →Learn Vim Grammar: Delete, Change, Yank & Text Objects
Mastering Vim's editing commands dramatically speeds up text manipulation. This guide covers essential operators like delete, change, and yank combined with motions and text objects, plus the powerful dot command to repeat actions effortlessly.
Code
" Delete a word
dw
" Change a word (delete then enter insert mode)
cw
" Yank (copy) a word
yw
" Delete entire line
dd
" Delete from cursor to end of line
D
" Delete a single character under cursor
x
" Change from cursor to end of line
C
" Replace a single character
r
" Yank entire line
yy
" Paste below cursor
p
" Paste above cursor
P
" Text objects examples:
" Change inside quotes (removes text inside quotes, keeps quotes)
ci"
" Delete around braces (removes braces and content)
da{
" Yank inner word (copies the word under cursor without spaces)
yiw
" Using counts to repeat commands:
3dw " delete 3 words
2dd " delete 2 lines
" Dot command repeats last change (e.g., after cw, press . to repeat)
.
Key Points
- Operators combined with motions perform actions, like dw to delete a word or cw to change a word.
- Text objects use 'i' for inner (excluding delimiters) and 'a' for around (including delimiters) to target text efficiently.
- Commands like ci", da{ and ci( work universally on quotes, braces, and parentheses for quick editing.
- Yank (copy) and paste commands include yy to copy a line, p to paste below, and P to paste above the cursor.
- The dot (.) command repeats your last change, enabling fast, repetitive editing with a single key.