Vi multiple command in one line

Viewed 2411

I want to achieve the following things in vi :

  • Remove first few columns
  • Remove lines starting with specific words
  • Remove everything after first word.

I have the following command with respect to above requirements

:%s/new page //g to remove first two columns.
:g/abc/d , :g/xyz/d , :g/ddd/d to remove lines starting with specific words.
:%s/ .*//g to remove everything after first word.

Overall I want to run the following commands :

:%s/new page //g
:g/abc/d
:g/xyz/d
:g/ddd/d
:%s/ .*//g

How can I execute all the above commands in one single command.

I have tried | but it did not worked.

:g/abc/d|:g/xyz/d|:g/ddd/d

I am getting the following error :

E147: Cannot do :global recursive

How can I achieve this. I want to execute all commands in one single command.

Thanks

2 Answers
Related