vimdiff and MacVim
I'd like to run vimdif开发者_开发知识库f on MacVim. Is there an easy way I'd be able to do it?
- From the terminal
If you have the mvim
script installed (it is in the dmg, just put it somewhere in your PATH
), you can just type in a shell:
mvim -d file1 file2
You can alias this to mvimdiff if you like.
- From within macvim
In macvim, like in vim , you can also use:
:e file1 :diffsplit file2 or :vert diffsplit file2
The second option gives you a vertical diff, which is usually more readable
If you symlink gvimdiff to mvim then mvim will start with -d etc. Vim and Mvim both look at what executable name they've been started with to determine how they behave. That how gvim and vim can be both the same executable on linux and it's the same on OSX.
Ok. I have kindof answered my own comment:
To diff two open buffers in vim, open them vertically, and select the first and type :diffthis
then the second one and type :diffthis
again.
This works for more than two buffers too =)
This worked for me on mac. I am using MacVim snapshot 72:
/Applications/MacVim.app/Contents/MacOS/Vim -d -g path_to_file1 path_to_file2
It works exactly like gvimdiff on windows.
Update: It even works with 3 files. This command will split the screen 3-ways and let you do a 3-way diff in macvim:
/Applications/MacVim.app/Contents/MacOS/Vim -d -g path_to_file1 path_to_file2 path_to_file3
精彩评论