我可以在 Vim 中使用什么正则表达式来查找 CVS 冲突?

发布于 2024-08-05 00:02:52 字数 51 浏览 1 评论 0原文

我可以在 Vim 中使用什么正则表达式来查找 CVS 和可能的其他版本控制系统中的冲突?

What is a regular expression I can use in Vim to find conflicts in CVS and possibly other version control systems?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

又爬满兰若 2024-08-12 00:02:52

这是一个查找整个冲突部分的正则表达式:

[<]\{7}.*\_.\{-}[=]\{7}\_.\{-}[>]\{7}.*

要在 vim 中搜索该正则表达式,只需按“/”键并粘贴该正则表达式字符串,然后按 Enter 键。

通常 CVS 冲突如下所示:

<<<<<<< file.c
Code from file.c
=======
Code from the repository version 1.2
>>>>>>> 1.2

保留本地版本的 Vim 搜索和替换命令:

:%s/[<]\{7}.*\n\(\_.\{-}\)[=]\{7}\_.\{-}[>]\{7}.*\n/\1/g

Vim 搜索和替换命令保留存储库版本:

:%s/[<]\{7}.*\_.\{-}[=]\{7}\n\(\_.\{-}\)[>]\{7}.*\n/\1/g

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
冰雪梦之恋 2024-08-12 00:02:52

我通常只是执行 /<<< 并按“n”,直到找不到更多匹配项。这是一种比尼尔的方法简单得多的方法,但它对我有用:)

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 :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文