What is a regular expression I can use in Vim to find conflicts in CVS and possibly other version control systems?
+6
A:
Here is a regular expression to find entire conflict sections:
[<]\{7}.*\_.\{-}[=]\{7}\_.\{-}[>]\{7}.*
And to search for that in vim, just press the '/' key and paste that regular-expression string, then press enter.
Usually CVS conflicts look like this:
<<<<<<< file.c
Code from file.c
=======
Code from the repository version 1.2
>>>>>>> 1.2
Vim search-and-replace command to keep local version:
:%s/[<]\{7}.*\n\(\_.\{-}\)[=]\{7}\_.\{-}[>]\{7}.*\n/\1/g
Vim search-and-replace command to keep repository version:
:%s/[<]\{7}.*\_.\{-}[=]\{7}\n\(\_.\{-}\)[>]\{7}.*\n/\1/g
Neil
2009-09-17 20:02:35
+2
A:
I usually just do /<<<
and press 'n' until I find no more matches. It is a much less sophisticated approach than Neil's, but it works for me :)
olsner
2009-09-20 21:47:49