1

my text look like this in several places of the file:

FDE
 PW91k
 XCNADD PBE
 ::FULLGRID
END


END 
eor

and I want to introduce a word two lines above "eor" word throughout. I have tried

 :,.-2/eor/foo/g 

and similar expressions, non worked so far.

Can you please help me with a trick that does this?

Thanks

1

You could use the following:

:g/^eor/-2normal Ofoo

Explanation:

  • :g/^eor/: For every line that starts with "eor"
  • -2: go two lines up
  • Ofoo: open a line above and enter "foo"

The :g stands for "global". See :help :g for details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.