How do I repeat the last substitute command quickly?
&
The & command in normal mode repeats the last :s substitution on the current line.
search #search #substitution #ex-commands #repeat #normal-mode
&
The & command in normal mode repeats the last :s substitution on the current line.
search #search #substitution #ex-commands #repeat #normal-mode
:%s//new/g
Leaving the search field empty in a :s command tells Vim to reuse the last search pattern from / or .
search #search #substitution #ex-commands #regex #productivity
:'<,'>s/\n/, /g
Vim's J command joins lines with a single space, but sometimes you need a custom separator like a comma, pipe, or semicolon.
editing #editing #ex-commands #visual-mode #substitution #lines
:%s/\(pattern1\)\(pattern2\)/\2\1/g
Vim's substitute command supports capture groups that let you match parts of text, remember them, and rearrange or reuse them in the replacement.