-
Notifications
You must be signed in to change notification settings - Fork 5
Some small improvements #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
a4b3879
9b9cb5c
0d854ec
a59bb38
944eaf3
199dd6c
201bf35
1cea674
e5e38c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| ############# | ||
| # various # | ||
| ############# | ||
| tags | ||
| *.swp | ||
| .netrwhist |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| *DirDiff.vim* A plugin to diff and merge two directories recursively | ||
|
|
||
| Text copied from www.vim.org/scripts/script.php?script_id=102 in 14/06/2012 | ||
| script karma Rating 1780/502, Downloaded by 11272 | ||
| created by William Lee | ||
|
|
||
| description | ||
| This is a utility that performs a recursive diff on two directories and | ||
| generate a diff "window". Based on that window you can perform various diff | ||
| operations such as opening two files in Vim's diff mode, copy the file or | ||
| directory recursively to the other, or remove the directory tree from the | ||
| source directory. | ||
|
|
||
| Doing the following will generate a diff window. | ||
|
|
||
| :DirDiff <A:Src Directory> <B:Src Directory> | ||
| e.g. | ||
| :DirDiff ../something/dir1 /usr/bin/somethingelse/dir2 | ||
|
|
||
| The following commands can be used inside the diff window: | ||
| 'Enter','o' - Diff open: open the diff file(s) where your cursor is at | ||
| 's' - Synchronize the current diff. You can also select | ||
| a range (through visual) and press 's' to synchronize differences | ||
| across a range. | ||
|
|
||
| - There are 6 Options you can choose when you hit 's': | ||
| 1. A -> B | ||
| Copy A to overwrite B | ||
| If A's file actually points to a directory, it'll copy it to B | ||
| recursively. | ||
| 2. B -> A | ||
| Copy B to overwrite A | ||
| If B's file actually points to a directory, it'll copy it to A | ||
| recursively. | ||
| 3. Always A | ||
| For the rest of the items that you've selected, | ||
| synchronize like (1). | ||
| 4. Always B | ||
| For the rest of the items that you've selected, | ||
| synchronize like (2). | ||
| 5. Skip | ||
| Skip this diff entry. | ||
| 6. Cancel | ||
| Quit the loop and exit. | ||
|
|
||
| 'u' - Diff update: update the diff window | ||
| 'x' - Sets the exclude pattern, separated by ',' | ||
| 'i' - Sets the ignore pattern, separated by ',' | ||
| 'a' - Sets additional arguments for diff, eg. -w to ignore white space, | ||
| etc. | ||
| 'q' - Quit DirDiff | ||
|
|
||
| The following comamnds can be used in the Vim diff mode | ||
| \dg - Diff get: maps to :diffget<CR> | ||
| \dp - Diff put: maps to :diffput<CR> | ||
| \dj - Diff next: (think j for down) | ||
| \dk - Diff previous: (think k for up) | ||
|
|
||
| You can set the following DirDiff variables. You can add the following | ||
| "let" lines in your .vimrc file. | ||
|
|
||
| Sets default exclude pattern: | ||
| let g:DirDiffExcludes = "CVS,*.class,*.exe,.*.swp" | ||
|
|
||
| Sets default ignore pattern: | ||
| let g:DirDiffIgnore = "Id:,Revision:,Date:" | ||
|
|
||
| If DirDiffSort is set to 1, sorts the diff lines. | ||
| let g:DirDiffSort = 1 | ||
|
|
||
| Sets the diff window (bottom window) height (rows) | ||
| let g:DirDiffWindowSize = 14 | ||
|
|
||
| Ignore case during diff | ||
| let g:DirDiffIgnoreCase = 0 | ||
|
|
||
| Dynamically figure out the diff text. If you are using and i18n version | ||
| of diff, this will try to get the specific diff text during runtime. It's | ||
| turned off by default. If you are always targetting a specific version of | ||
| diff, you can turn this off and set the DirDiffText* variables | ||
| accordingly. | ||
| let g:DirDiffDynamicDiffText = 0 | ||
|
|
||
| String used for the English equivalent "Files " | ||
| let g:DirDiffTextFiles = "Files " | ||
|
|
||
| String used for the English equivalent " and " | ||
| let g:DirDiffTextAnd = " and " | ||
|
|
||
| String used for the English equivalent " differ") | ||
| let g:DirDiffTextDiffer = " differ" | ||
|
|
||
| String used for the English equivalent "Only in ") | ||
| let g:DirDiffTextOnlyIn = "Only in " | ||
|
|
||
|
|
||
| install details | ||
| Put this file in your ~/.vim/plugin | ||
|
|
||
|
|
||
| vim: tw=78:ts=8:ft=help:fdm=marker | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -308,13 +308,16 @@ endif | |
| if !exists("g:DirDiffTextOnlyInCenter") | ||
| let g:DirDiffTextOnlyInCenter = ": " | ||
| endif | ||
| " If true, the buffer is deleted after being displayed in a diff | ||
| if !exists("g:DirDiffBufferDelete") | ||
| let g:DirDiffBufferDelete = 1 | ||
| endif | ||
|
|
||
| " Set some script specific variables: | ||
| " | ||
| let s:DirDiffFirstDiffLine = 6 | ||
| let s:DirDiffALine = 1 | ||
| let s:DirDiffBLine = 2 | ||
| let s:DirDiffIsRunning = 0 | ||
|
|
||
| " -- Variables used in various utilities | ||
| if has("unix") | ||
|
|
@@ -368,8 +371,8 @@ endif | |
|
|
||
|
|
||
| function! <SID>DirDiff(srcA, srcB) | ||
| if(s:DirDiffIsRunning == 0) | ||
| let s:DirDiffIsRunning = 1 | ||
| tabedit | ||
| if &guioptions =~# 'T' | ||
| aunmenu ToolBar.GUI | ||
| amenu ToolBar.PrevChange [c | ||
| tmenu ToolBar.PrevChange Previous Change | ||
|
|
@@ -390,9 +393,6 @@ function! <SID>DirDiff(srcA, srcB) | |
| tmenu ToolBar.UpdateDiff Update Diff | ||
| amenu ToolBar.QuitDiff :call <SID>DirDiffQuit ()<CR> | ||
| tmenu ToolBar.QuitDiff Quit Diff | ||
| else | ||
| echo "DirDiff is running" | ||
| return | ||
| endif | ||
| " Setup | ||
| let DirDiffAbsSrcA = fnamemodify(expand(a:srcA, ":p"), ":p") | ||
|
|
@@ -434,7 +434,6 @@ function! <SID>DirDiff(srcA, srcB) | |
| let error = <SID>DirDiffExec(cmd, 0) | ||
| if (error == 0) | ||
| redraw | echom "diff found no differences - directories match." | ||
| let s:DirDiffIsRunning = 0 | ||
| return | ||
| endif | ||
| silent exe "edit ".DiffBuffer | ||
|
|
@@ -475,9 +474,11 @@ function! <SID>DirDiff(srcA, srcB) | |
| 0 | ||
| setlocal nomodified | ||
| setlocal nomodifiable | ||
| setlocal buftype=nowrite | ||
| setlocal buftype=nofile | ||
| setlocal bufhidden=delete | ||
| setlocal noswapfile | ||
| setlocal nowrap | ||
| file DirDiff | ||
|
|
||
| " Set up local key bindings | ||
|
|
||
|
|
@@ -563,29 +564,26 @@ function! <SID>DirDiffQuit() | |
| let in = confirm ("Are you sure you want to quit DirDiff?", "&Yes\n&No", 2) | ||
| if (in == 1) | ||
| call <SID>CloseDiffWindows() | ||
| aunmenu ToolBar.PrevChange | ||
| aunmenu ToolBar.NextChange | ||
| aunmenu ToolBar.PutChange | ||
| aunmenu ToolBar.GetChange | ||
| aunmenu ToolBar.-DDSep2- | ||
| aunmenu ToolBar.PrevFile | ||
| aunmenu ToolBar.NextFile | ||
| aunmenu ToolBar.SyncFiles | ||
| aunmenu ToolBar.UpdateDiff | ||
| aunmenu ToolBar.QuitDiff | ||
| amenu ToolBar.GUI :call <SID>DirDiffGUI ()<CR> | ||
| tmenu ToolBar.GUI Start DirDiff with GUI | ||
| if &guioptions =~# 'T' | ||
| aunmenu ToolBar.PrevChange | ||
| aunmenu ToolBar.NextChange | ||
| aunmenu ToolBar.PutChange | ||
| aunmenu ToolBar.GetChange | ||
| aunmenu ToolBar.-DDSep2- | ||
| aunmenu ToolBar.PrevFile | ||
| aunmenu ToolBar.NextFile | ||
| aunmenu ToolBar.SyncFiles | ||
| aunmenu ToolBar.UpdateDiff | ||
| aunmenu ToolBar.QuitDiff | ||
| amenu ToolBar.GUI :call <SID>DirDiffGUI ()<CR> | ||
| tmenu ToolBar.GUI Start DirDiff with GUI | ||
| endif | ||
| bd! | ||
| endif | ||
| let s:DirDiffIsRunning = 0 | ||
| endfun | ||
|
|
||
| " Open GUI for DirDiff | ||
| function! <SID>DirDiffGUI() | ||
| if(s:DirDiffIsRunning == 1) | ||
| echo "DirDiff is running" | ||
| return | ||
| endif | ||
| let workingDir = $HOME.'/workspace/' | ||
| let lft = browsedir("Select the left side to compare", workingDir) | ||
|
|
||
|
|
@@ -616,12 +614,22 @@ function! <SID>CloseDiffWindows() | |
| wincmd k | ||
| " Ask the user to save if buffer is modified | ||
| call <SID>AskIfModified() | ||
| bd! | ||
| if g:DirDiffBufferDelete | ||
| bd! | ||
| else | ||
| diffoff | ||
| q | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not good to assume recursive map. Should
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this isn't a map, but an ex command (as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops, my mistake. |
||
| endif | ||
| " User may just have one window opened, we may not need to close | ||
| " the second diff window | ||
| if (&diff) | ||
| call <SID>AskIfModified() | ||
| bd! | ||
| if g:DirDiffBufferDelete | ||
| bd! | ||
| else | ||
| diffoff | ||
| q | ||
| endif | ||
| endif | ||
| endif | ||
| endfunction | ||
|
|
@@ -665,8 +673,11 @@ function! <SID>DirDiffOpen() | |
|
|
||
| call <SID>CloseDiffWindows() | ||
|
|
||
| " Ensure we're in the right window | ||
| exec thisWindow.'wincmd w' | ||
| " Ensure we're in the right window - check if there is any splits before | ||
| " executing wincmd to avoid error beep | ||
| if winnr("$") != 1 | ||
| exec thisWindow.'wincmd w' | ||
| endif | ||
|
|
||
| let line = getline(".") | ||
| " Parse the line and see whether it's a "Only in" or "Files Differ" | ||
|
|
@@ -713,12 +724,13 @@ function! <SID>DirDiffOpen() | |
| call <SID>DirDiffResize() | ||
| exe (b:currentDiff) | ||
| " Center the line | ||
| exe ("normal z.") | ||
| exe ("normal! z.") | ||
| else | ||
| echo "There is no diff at the current line!" | ||
| endif | ||
|
|
||
| exec thisWindow.'wincmd w' | ||
| wincmd k | ||
| normal! gg]c | ||
| endfunction | ||
|
|
||
| " Ask the user to save if the buffer is modified | ||
|
|
@@ -863,7 +875,6 @@ function! <SID>DirDiffSyncHelper(AB, line) | |
| else | ||
| echo "There is no diff here!" | ||
| " Error | ||
| let s:DirDiffIsRunning = 0 | ||
| return 1 | ||
| endif | ||
| if (operation == "Copy") | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The help text at the top of dirdir.vim should be removed and merged with this doc file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it would be better to implement an index, include headings and internal references (DirDiff-options, etc), as explained in
:help write-local-help. This is just a starting point, which I find better than no help file at all :-)