vimtricks.wiki Concise Vim tricks, one at a time.

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 !command runs a shell command without prompting
  • :silent %s/old/new/ge substitutes without showing results
  • :silent! command also 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
  • :redraw may be needed after :silent ! to refresh the screen
  • Combine with :execute for dynamic silent commands

Next

How do you yank a single word into a named register?