While working with Alfresco files I had to search and find numerous strings within XML files. The task included replacing Hex Colour Codes, this was achieved by using the following Vim command:
:s/#code1/#code2
Replaces the first instance of #code1 with #code2
—–
:s/#code1/#code2/g
The above command replaces all code in the file with code2 within a single line.
——
By adding :% the whole file will be searched.
:%s/#code1/#code2/g
This command replaces all code in the file with code2 within the whole file.
—–
:%s/#code1/#code2/gc
Replaces all code in the file with code2 within the whole file but asks for confirmation first.
—-
:50,$/#code1/#code2/gc
Replaces the the code after line 50 to the end of the file