What is the difference between cw and ciw when changing a word?
cw vs ciw
The cw and ciw commands both change a word, but they behave differently depending on cursor position.
editing #editing #text-objects #motions #normal-mode #productivity
21 results for "ciw"
cw vs ciw
The cw and ciw commands both change a word, but they behave differently depending on cursor position.
editing #editing #text-objects #motions #normal-mode #productivity
ciw
The ciw command deletes the inner word under the cursor and drops you into insert mode so you can type a replacement.
ciw""<Esc>P
Vim doesn't have a built-in "surround" operator, but you can wrap any word in quotes or brackets with a short sequence: ciw""P.
editing #editing #text-objects #normal-mode #productivity #surround
:set iskeyword+=-
By default, Vim treats hyphens, dots, and many punctuation characters as word boundaries.
ciw + new text + Esc, then n.
The ciw command followed by new text, combined with and .
qq;.q then @q or @@
The dot command (.
:let @q then use in nnoremap
Macros are stored in registers as plain keystroke strings.
:let @q = 'commands'
Macros in Vim are just text stored in named registers.
ce
The ce command changes from the cursor position to the end of the current word.
diw
The diw command deletes the inner word under the cursor.
qaciw"<C-r>""<Esc>wq
This macro wraps the current word in double quotes by changing the word, inserting quotes around the original content, and moving to the next word.
:setlocal iskeyword+=-
The iskeyword option defines which characters are part of a "word" for motions like w, b, e, , and text objects like iw.
w vs W, b vs B, e vs E
Vim distinguishes between "words" (sequences of keyword characters) and "WORDS" (sequences of non-blank characters).
.
The .
yyp
The yyp command duplicates the current line by yanking it and immediately pasting it below.
:let @q = "dwelp"
Recording macros with q works well for simple sequences, but complex macros with special keys can be hard to get right in one take.
yiw
How it works The command yiw yanks (copies) the inner word under the cursor.
0 or ^ at start of macro
A common macro pitfall is assuming the cursor starts at a specific column.
"_d
The "d command deletes text using the black hole register ("), which discards the deleted content instead of storing it.
oil.nvim: edit directory listing like a buffer
oil.