Reputation: 17
Say there are two lines like
1:Could be anything
2:FOO is a word
Now I want edit the #1 line by searching /FOO
using :%s
, or I want to add a new line above the line which has FOO in it.
Upvotes: 0
Views: 62
Reputation: 196906
:help :global
is your friend.
This command:
:g/FOO/-2s/any/some
would turn:
1:Could be anything
2:FOO is a word
into:
1:Could be something
2:FOO is a word
And this command:
:g/FOO/normal! O
would turn:
1:Could be something
2:FOO is a word
into:
1:Could be something
2:FOO is a word
Upvotes: 3