Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

redirection and vim

Tags:

linux

vim

I was wondering if there's a way to see the output of any command, straight inside vim, rather than first redirecting it into a file and then opening that file.

E.x. I need something like $ gvim < diff -r dir1/ dir2/

This gives ambiguous redirect error message

I just want to see the diffs between dir1 and dir2 straight inside gvim.

Can any one provide a nice hack?


2 Answers

diff file1 file2 | vim -R -

The -R makes it read-only so you don't accidentally modify the input (which may or may not be your desired behavior). The single dash tells vim to reads its input over standard input. Works for other commands, too.

like image 197
jvasak Avatar answered Sep 12 '25 23:09

jvasak


Also, when already in Vim:

:r! diff file1 file2
like image 42
skinp Avatar answered Sep 12 '25 21:09

skinp