read Read
read Read

Reputation: 6063

how to do conditional replacing using vim

I want to replace word with WORD, but only on the lines which start with -. Anybody knows how to do it?

Upvotes: 9

Views: 3520

Answers (1)

rampion
rampion

Reputation: 89053

:%g/^-/s/word/WORD/g

it's just a normal search and replace, but using g// to filter the lines you want to run it on.

Upvotes: 13

Related Questions