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 know how to run shell commands within vim using :!r and :!, but is there a way I can do that from outside, i.e. from bash?

Something along the lines of vim 'ls -al'. The output of ls should be in vim and editable.

share|improve this question

migrated from Jan 16 '13 at 1:31

This question came from our site for professional and enthusiast programmers.

up vote 14 down vote accepted

You can read stdin

$ ls -al | vim -
share|improve this answer
Perfect. Thanks! – WhoDares Jan 16 '13 at 0:22

Execute the command the same way you would any command from the command line.

$ vim '+r !ls -al'
share|improve this answer
+1 vim is everywhere... nice – Kent Jan 16 '13 at 0:24

You can use bash process substitution like this:

vim <(ls -al)

See "Process Substitution" subsection of the bash manual:

man -P 'less +/Process\ Substitution' bash
share|improve this answer

Your Answer


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