Abhishek Das
Abhishek Das

Reputation: 17

How to edit a earlier line from the line that was originally searched in gvim editor

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

Answers (1)

romainl
romainl

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

Related Questions