How do I run a command without showing its output?
Answer
:silent command
Explanation
The :silent prefix suppresses all output from a command, including messages and prompts. This is useful for scripting and automation.
How it works
:silent !commandruns a shell command without prompting:silent %s/old/new/gesubstitutes without showing results:silent! commandalso suppresses error messages
Example
:silent !open . " Open file manager without prompt
:silent %s/TODO/DONE/ge " Replace without message
:silent! bdelete 5 " Delete buffer 5, ignore error if not found
Tips
:silent!suppresses both output and errors- Useful in autocommands and scripts
:redrawmay be needed after:silent !to refresh the screen- Combine with
:executefor dynamic silent commands