by JepZ · 8y ago · 0 comments
If you are used to sed it should be easy, as it is pretty much the same. I keep using this pattern over and over again:
:%s/search/replace/gc
The '%' is some sort of reference to the file you are currently editing and therefore you are doing a replace on the whole file. You can see the difference in combination with some visual selection. When you select some text and press ':' it opens as ":'<,'>" :% # replace in the whole file
:'<,'> # replace in the current selection
The 'gc' flags at the end are: g=global to replace multiple times per line
c=confirm to let vim ask you about every replacement
Sometimes its just easier to let vim ask you a few times than to spend 5 minutes to figure out the 100% correct regex.