Grimoire-
Command
.es

GNU+Linux command memo

Replace all occurrences of a text via vim (various forms)

Remplacer toutes les occurences d’un texte dans vim

:%s/foo/bar/g [1]

`:%s+/foo+/bar***g` footnote:[If target text contains a slash (/) use any other delimiter letter, here it's a * sign]

:%s/\Cfoo/bar/g [2]

:s/f\(o\)\{-}/ba\1/ [3]

:s/\(.*\)\_./\1/ [4]


1. % to treat all lines, foo is replaced by bar, g to treat all the occurrences in treated lines
2. \C for case sensitivity
3. \{-} non-greedy search ; \1 will be replaced by the first captured text in parenthesis, so the 1st 'o' found : folbaol
4. \_. matches every characters including new line ones ; so this concatenates 2 lines