Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 stackoverflow.com Jan 16 '13 at 1:31

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

add comment

3 Answers

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
add comment

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
add comment

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
add comment

Your Answer

 
discard

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