Skip to content

Commit

Permalink
Version 1.0: Initial upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathaniel Soares authored and vim-scripts committed Oct 7, 2012
0 parents commit 5ce6e12
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README
@@ -0,0 +1,7 @@
This is a mirror of http://www.vim.org/scripts/script.php?script_id=4247

Calling :TabDiff will open each pair of buffers in a vertically split tab and in diff mode. Now you can

vim -c "silent :TabDiff" a A b B c C

To diff a bunch of files at once in different tabs.
9 changes: 9 additions & 0 deletions README.md
@@ -0,0 +1,9 @@
# Vim TabDiff
## A different way to vimdiff

Gives you the tabdiff command, which will open all your pairs of buffers in
opposing vertical splits in different tabs. Now you can

vim -c 'silent :TabDiff' A a B b C c

And nicely diff all those files at once.
35 changes: 35 additions & 0 deletions doc/tabdiff.vim
@@ -0,0 +1,35 @@
*tabdiff.txt* Diff in Tabs

Author: Nate Soares <http://so8r.es/>
License: GPLv2 (http://www.gnu.org/licenses/gpl-2.0.html)

INTRODUCTION *tabdiff*

Diff many files in multiple tabs.

COMMANDS *tabdiff-commands*

*tabdiff-:TabDiff*
:TabDiff
Creates a new tab page for each consecutive pair of buffers
(split vertically, with the first on the left and the second
on the right) and sets all of the windows to diff mode. The
original tab page is closed.

Intended usage is to start vim with alternating 'old' and
'new' files and then invoke this function immediately. It
expects there to be only one tab and an even number of
buffers, as in: >
vim -c 'silent :TabDiff' \
/tmp/original/apples apples \
/tmp/original/oranges oranges
<

ABOUT *tabdiff-about*

Grab the latest version or report a bug on GitHub:

http://github.com/Soares/butane.vim

vim:tw=78:ts=8:noet:ft=help:norl:
49 changes: 49 additions & 0 deletions plugin/tabdiff.vim
@@ -0,0 +1,49 @@
" tabdiff.vim A differetn way to diff.
" Author: Laurence Gonsalves <laurence@xenomachia.com>
" Maintainer: Nathaniel Soares <http://so8r.es/>
" Version: 1.0
" License: GPLv2 <http://www.gnu.org/licenses/gpl-2.0.html>

if exists("g:loaded_tabdiff") || &cp || v:version < 700
finish
endif
let g:loaded_tabdiff = 1


" Creates a new tab page for each consecutive pair of buffers (split
" vertically, with first on left and second on right) and sets all of the
" new windows to diff mode. The original tab page will also be closed.
"
" Intended usage is to start vim with alternating "old" and "new" files,
" and then invoke this function. It expects there to be only one tab
" open and 2*n buffers.
"
" Example:
" gvim -c 'silent call TabDiff()' old-foo foo old-bar bar
"
" This will result in two tabs: old-foo+foo diff, and old-bar+bar diff.
function! tabdiff#TabDiff()
let s:tab_multi_diff = 0
argdo call s:AddBufferToTab()
tabclose
endfun
command! TabDiff call tabdiff#TabDiff()


" Helper function used by TabDiff(). Adds current buffer to new tab
" or last tab as appropriate, and sets new window's "diff" option.
function! s:AddBufferToTab()
let buf = bufnr("%")
if s:tab_multi_diff
tablast
vsplit
wincmd w
else
tab split
tabmove
endif
let s:tab_multi_diff = ! s:tab_multi_diff
exe 'b ' . buf
diffthis
tabfirst
endfun

0 comments on commit 5ce6e12

Please sign in to comment.