- Basic Substitution: Using
:s
to replace the first occurrence of text on the current line. - Replacing Text on Specific Lines: Employing
:s
with line numbers or ranges (e.g.,:90,110s
) to replace text within defined line ranges. - Global Substitution: Utilizing
:s
with theg
flag (:s/pattern/replacement/g
) to replace all occurrences of text on a line or throughout the file. - Pattern-based Substitution: Using regular expressions with the substitute command. For instance, replacing the first character of each word with its uppercase representation using
:%s/^./\u&/g
.

vim - 0 How to Replace Text in a File With VIM
TL;DR →
1. Basic Substitution: Using `:s` to replace the first occurrence of text on the current line. 2. Replacing Text on Specific Lines: Employing line numbers or ranges (e.g., `:90,110s`) to replace text within defined line ranges. 3. Pattern-based substitutions: Using regular expressions with the substitute command.
This story on HackerNoon has a decentralized backup on Sia.
Meta Data: 📄