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'm trying to redirect the output of a command to vim using the - argument, but it doesn't seem to work on OS X. For example, if I type

$ ls | vim - 

on the command line on one of my Linux machines, the output of ls is correctly piped to vim. But when I do the same thing on any of my OS X machines, I get

$ ls | vim -
Vim: Reading from stdin...

And it just hangs there until I hit CTRL-D.

Any idea why this would be happening and how to actually redirect the output of a command to vim?

For reference, I'm using OS X 10.6.4 (and 10.6.5) with vim 7.2 (and 7.3) with bash as my shell.

share|improve this question

3 Answers 3

up vote 1 down vote accepted

I would expect a hand like this if their were problems with permissions. This page expands on Vi on OS X more than I ever could. Rather than just cut and paste their answers, I thought I'd point you to it to see if it helps.

http://macvim.org/OSX/index.php

share|improve this answer
    
Reading through that whole page, I got to a section where it mentioned that forking was non-standard and that to fork, one should provide the whole path to binary. Doing that, piping a command's output to vim worked fine. So I figured I'd just make an alias for vim that would provide the whole path, and that's when I noticed: sometime, years ago, I had already created an alias for vim: alias vim='export TERM=xterm-color; vim'. I fixed this to alias vim='TERM=xterm-color vim' and now it works just as it should. Thanks for indirectly leading me to the solution :-). –  RTBarnard Nov 20 '10 at 6:13
    
Any time I can cluelessly get someone to the right place, well, luck is better than skill... :) –  Everett Nov 20 '10 at 6:23

Don't use macvim.org; it's very outdated. The correct site for macvim is http://code.google.com/p/macvim. Contained therein are links to the wiki and other sources of info.

share|improve this answer

Use the -f option for macvim. And the -R option to quit without being asked to save.

ls | mvim -Rf -

Another example... svn diff | mvim -Rf -

-f option

-f  or  --nofork    Foreground: Don't fork when starting GUI

-R option

-R          Readonly mode (like "view")
share|improve this answer

Your Answer

 
discard

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

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