Friday, July 22, 2011

How To: Substitute words using vim

It's always nice when you learn something useful. I've been using vim for a while but I only use a fraction of its functionality. Today I picked up a nice little feature for substituting words. While in Normal Mode use:
:%s/word/substitution/gc
The g and c on the end are not required but they suit my needs. The g is to search globally and the c is used so that it will ask you to confirm the substitution each time it comes across a matching work. Always better to play it safe.

No comments: