
On 11.06.12 16:21, Russell Coker wrote:
Is there a VIM command that can delete the current line and all following lines until it meets a line starting with "---" (or "diff" depending on the type of diff file)?
I'm still working on merging patches and looking for ways to make it less painful.
OK, you're not blindly applying the patches, but manually selecting a subset of the changes to apply. There are two methods I've used for that, over the years: a) Blindly apply the patches to a copy of the files, then either use $ sdiff -o result patched.file unpatched.file Answer l or r <CR> to choose whether to apply each region of the patch. (In full context, it is easier than trying to decide based only on the patch, usually.) OR, instead of sdiff, using vim: ( :h vimdiff ) $ vimdiff -o file1 file2 # -o => Horizontal split, good for long # lines. Commands to get started: ]c Move to next diff. [c Move to previous diff. You're in vim, and can make changes to synchronise the files, or make other tweaks while you're there. :h diffput :h diffget :h diffupdate To save on keystrokes, I have the following in .vimrc: " For vimdiff: noremap <F9> :diffget<CR>]c " Copy 1st <- 2nd file & go to next change. noremap <F10> :diffput<CR>]c " Copy 1st -> 2nd file & go to next change. b) OTOH, if it's only merge conflicts which merit immediate attention, blindly apply the patches to a copy of the files, which are checked out from CVS. Do the merge of several thousand files with a cvs update, cvs commit sequence. (OK, git then, nowadays. :) The attached script, which I used to speed up resolution of the merge conflicts, might be adaptable to your use case. Even if it's not just merge conflicts you're targeting, then changing the /^<</ , /^>>/ delimiters, and the /^==/ separator, to suit unified diff (or whatever you have), could come close to handling the task? It works in a tmp directory, and prompts before overwriting the input file. Hopefully some variant of what has helped me perform multi-thousand file code merges, with innumerable changes, in an afternoon will be of some use. Erik -- Duct tape is like the force. It has a light side, and a dark side, and it holds the universe together. - Carl Zwanzig