On Thu, September 22, 2011 5:35 am, [email protected] wrote: > this some other unchaged stuff > - this is a line with the OLDKEYWORD > + this is a line with the NEWKEYWORD > this some other unchaged stuff > > I tried a g/blurb/d kind of command, > which nearly deletes all of the file, but after > undoing the deletion, all according lines where > correctlz highlighted (via hlsearch) > > the expression was: > g!/^-.*\n+.*$/d > > I am asking myself...what did I wrong here so badly
First, I found it hard to find out, what your problem was. So please be precise in what you did, what you expected to see and what really happened. My guess is, that you wanted to keep all lines that changed (e.g. starting with either a + or a -). You used a multi-line regex as pattern for the g command. In my experience, this usually does not do what you want, since the g command works linewise. In your case when the cursor is on the first line of your sample text, Vim will notice that the pattern does not match and delete that line. Now the cursor will move on to the next line. Vim notices, that this line does match the pattern and won't delete the line and moves on the the next line (the one starting with +). Now Vim notices, that this line again does not match that pattern /^-.*\n+.*$/, so it will delete also this line, since this line does not start with a '-' but with a '+'. I think a better approach would be to use something like this: :v/^[+-]/d which will delete all lines, that start neither with a '+' nor with a '-' (this is slightly different than you approach, in which you always want to keep for each line starting with '-' the line immediately below that starts with a '+'. But in my experience, you usually don't have exactly such patterns in diffs, anyway and I'd like to see all changes). regards, Christian -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php
