1

I'm trying to automatically delete useless headers when calling vim from mutt. I've tried running vim with the following command.

vim +'0,/^$/g/^\(Cc\|Bcc\|Reply-To\): $/d' /tmp/test

However, I get the following feedback when it starts.

"/tmp/test" 11L, 60C
3 fewer lines
Press ENTER or type command to continue

For testing purposes, if I remove the range and g (i.e. 0,/^$/g), the command is as follows, and I do not get the additional prompt.

vim +'g/^\(Cc\|Bcc\|Reply-To\): $/d' /tmp/test

Why do I get the prompt for the first command? How can I suppress it?

Edit

I seem to only get the prompt when the command deletes three lines, e.g. when /tmp/test consists of the following.

To: Foo
Cc: 
Bcc: 
Reply-To: 

foo
bar

However, when there are only two lines deleted, I get no prompt, e.g. when /tmp/test consists of the following.

To: Foo
Cc: Bar
Bcc: 
Reply-To: 

foo
bar
7
  • Try adjusting the 'cmdheight' option before running the global command.
    – VanLaser
    Oct 19, 2015 at 12:15
  • @VanLaser This works well. I do set cmdheight=2 before the command, then set cmdheight=1 after. I'd upvote if it were an answer.
    – Sparhawk
    Oct 19, 2015 at 20:57
  • I've also found references to both answers here.
    – Sparhawk
    Oct 19, 2015 at 20:58
  • It's ok :) the silent answer is actually better/shorter.
    – VanLaser
    Oct 19, 2015 at 21:46
  • @VanLaser I actually quite like yours too, because it still notifies in case of error. silent (obviously) gives no indication if a command has failed.
    – Sparhawk
    Oct 19, 2015 at 22:07

1 Answer 1

4

Use :silent to suppress the output of the command.

vim +'silent 0,/^$/g/^\(Cc\|Bcc\|Reply-To\): $/d' /tmp/test
2
  • Thank you; works well (+1). However, do you have any idea why I get the prompt for this command (my first question)? And why only when it matches thrice?
    – Sparhawk
    Oct 19, 2015 at 20:50
  • @Sparhawk As already mentioned in comments to your question, when the output exceeds the value of 'cmdheight' it causes the hit-enter prompt. Vim does this to ensure you see ask the output. Since you don't care about the output, :silent is the right way to avoid the prompt.
    – jamessan
    Oct 19, 2015 at 22:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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