This question on StackOverflow triggered my curiosity.

What does :silent !echo doing?

The first time I saw something like :excommand !shellcommand was when I was looking for a way to save a read-only file from within a non-sudo Vim session. Indeed I found the famous How does the vim “write with sudo” trick work?. In that case, however, it's "easy" to search for :help :w and scroll down a bit find the entry :[range]w[rite] [++opt] !{cmd} which describes the meaning of that !.

In the case of :silent, instead, doing :help :silent doesn't bring anywhere the question mark is used after a space and before {command}.

My understanding is that :silent !echo is working mostly like :!echo but without showing any of the output or of the underlying shell, and sending the cursor to the top of the screen. I've recorded a screencast for reference. (NOTE: All those horizontal lines that you see happen to be present only in the screencast, for some reason, there's no such a thing in my system.)

This question seems related.


1 Answer 1


Well, there's :silent:

:sil[ent][!] {command}  Execute {command} silently.  Normal messages will not
                        be given or added to the message history.

and there's :!

:!{cmd}         Execute {cmd} with the shell.  See also the 'shell'
                and 'shelltype' option.

Your hunch is mostly correct; I'm not sure why the cursor goes to the top of the screen, but it's probably because the command outputs a drawing code (termcap stuff), which vim is also using to draw on the screen.

Your Answer

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

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