Vi Editor: how to replace/delete ?

(1) Using VIM (Vi improved), how to delete "ABB_Hello" and "ABB_World" with just one command?

(2) How to remove those spaces in the beginning of Line 3 and 4 with just one command?

ABB_Hello Line 1;
ABB_World Line 2;
           Line 3;
           Line 4;
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

(1) With a single command you cannot delete both the words! You will have to use delete word command twice.
(2) Goto the first column on each line and (in escape mode) enter "dw" (without quotes), the spaces will get deleted.
     If you know the number of spaces in the begining of those lines and if they are same, then you can remove them with a single command like this(editor prompt): Goto the ":" prompt inside vim. And give the following command there :g/           /s///g
This will work only if the number of spaces is exactly same!
codenamecharlieAuthor Commented:

VI is not smart enough to delete those words with just one single command? Disappointing.....

I thought Vi is powerful enough to do this... ?
Can you please show me any other editor which can do this!?
CEOs need to know what they should worry about

Nearly every week during the past few years has featured a headline about the latest data breach, malware attack, ransomware demand, or unrecoverable corporate data loss. Those stories are frequently followed by news that the CEOs at those companies were forced to resign.



3,4s/^[ ]*//
(there is a space inside the brackets)
I forgot the upper case letters:
To delete all occurrences of ABB_Hello:


To delete all occurrences of ABB_World:


To delete the spaces, you have to know how many spaces there are:

:%s/^     //g
:g/^ABB_[^ ]*/s///
:3,4 s/^ *//

(second one already suggested by scn:)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
codenamecharlieAuthor Commented:
OK, scn and ahoffmann's solutions work, other guys either misunderstand my question or just gimme wrong answers.

BTW, ahoffmann, may you pls explain to me the meaning of the command:

 :g/^ABB_[^ ]*/s///   ???

does 'g' mean "global" ???
what is [^ ]* ? is there a space after ^   ???
also, what is s///     ???   looks weird

Many thx!
Hi codenamecharlie,
The solution I gave for the 2nd Q works fine! Also, it is simple to understand than others!:-)

But I accept that the answers provided by scn and ahoffmann are better than the solution I gave:-))
g is different from :g
:g means "process hole file"
s/// used in :g means that the matched pattern is replaxed by nothing:
  s//  -- matches pattern
    // -- replace by nothing
or more syntacticaly: s/pattern/replace/
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.