Replace matches only on the current line.

Section: Substitution patterns

Substitute on current line

vim
vim
:s/old/new/g
Explanation

The `g` flag replaces all matches on the current line.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Substitution patterns
Substitute in entire file
Perform a global replacement across the buffer.
OpenIn sheetvimsame section
Substitute inside visual selection
Restrict replacement to a selected range.
OpenIn sheetvimsame section
Clear search highlight
Remove visual search highlighting.
OpenIn sheetvimsame section
Search forward
Find the next match after the cursor.
OpenIn sheetvim1 tag match
Record a macro
Start recording keystrokes into a register.
OpenIn sheetvim1 tag match
Search backward
Search upward through the file.
OpenIn sheetvim1 tag match