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]
Accross multiple files : Replace text accross multiple files / buffers in vim.
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 :
fol
→ baol
4. \_. matches every characters including new line ones ; so this concatenates 2 lines