Archive for ‘Linux’

10/05/2008

Vim tip – replace

:%s/foo/bar/g = find each occurance of 'foo' and replace it with 'bar' without asking for confirmation

:%s/foo/bar/gc = find each occurance of 'foo' and replace it with 'bar' asking for confirmation first

:%s//bar/gc = find (match exact word only) and replace each occurance of 'foo' with 'bar'

:%s/foo/bar/gci = find (case insensitive) and replace each occurance of 'foo' with 'bar'

:%s/foo/bar/gcI = find (case sensitive) and replace each occurance of 'foo' with 'bar'

Further reference : ‘:help substitude’

Tags: ,
Follow

Get every new post delivered to your Inbox.