Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use gVim 7.3.46 on Win 7.

It is pretty straightforward to use argdo to search args files for a pattern and replace it while suppressing errors and requiring confirmation.

:argdo %s/pattern/replace/gec | update

However, I would like to delete entire lines that contain the pattern. I use the following.

:argdo %/pattern/d | update

But I can't suppress errors or require confirmation. Is there a way to do this? Thanks!

(Also, is there a way to set "more" off? Thanks!)

share|improve this question
up vote 7 down vote accepted

You can suppress some errors by preceding the command with :silent. To delete lines containing a pattern, the command is :g/pattern/d. So the following should do what you want.

:silent argdo g/pattern/d | update


:help :silent
:help :g

To turn "more" off,

:set nomore

Also see

:help 'more'
:help more-prompt
:help messages

How to deal with confirmations depends on what needs to be confirmed. Putting a ! after a command often means, "Do it anyway."

share|improve this answer
Thanks! Is there I way that I could get the s///gec functionality? Maybe something like argdo %s/pattern/^$//gec? But I think this just deletes the contents on the line, not the whole line. – Richard Herron May 31 '12 at 13:49
To get s///gec to delete an entire line, use this: %s/.*pattern.*\n//ec. The \n will match the end-of-line marker even for a DOS file. The g isn't necessary if you're deleting the entire line. – garyjohn May 31 '12 at 15:33
this is so awesome thank you! :set nomore, :arga **/* and :argdo execute 'normal gg=G' | w fixes all the ugly indenting on a project I'm working on. – shicholas Apr 16 '14 at 23:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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