GVIM 搜索和替换文本的问题

发布于 2024-12-04 07:38:28 字数 456 浏览 1 评论 0原文

我们希望使用 GVIM 搜索和替换一些文本。 我们必须识别任何前面没有逗号且以逗号开头的“(忘记行首和行尾的那些)。 然后将其替换为 '

在识别搜索字符串方面,我们已经破解了:

/[^,]"[^,]

在用更正替换文本方面,我们已经得到了:

:.,$s/[^,]”[^,]/’/gc

但这

似乎删除了 3 个字符,即

,"SHELL 1" DIAMETER","help"
,SHELL 'DIAMETER help,"help"

我们需要是能够使:

,"SHELL 1' DIAMETER","help

变成

,SHELL 1'", help

we're looking to search and replace some text using GVIM.
We have to identify any " that is not preceeded AND proceeded by a comma (forgetting the ones at the beginning and end of the line).
Then replace those with '

In terms of identiying the search string, we've got that cracked with:

/[^,]"[^,]

And in terms of replacing the text with the correction, we have got as far as:

:.,$s/[^,]”[^,]/’/gc

BUT

this seems to be deleting 3 characters i.e.

,"SHELL 1" DIAMETER","help"
,SHELL 'DIAMETER help,"help"

What we need is something that will make:

,"SHELL 1' DIAMETER","help

into

,SHELL 1'", help

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

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

发布评论

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

评论(1

神也荒唐 2024-12-11 07:38:28

您只需要定义与 \zs\ze 匹配的开始和结束位置

/[^,]\zs"\ze[^,]

如果您已经使用 / 定义了搜索词, 您可以将搜索替换的搜索部分保留为空,它将使用当前搜索。

:.,$s//’/gc

you just need to define the start and end of you match with \zs and \ze

/[^,]\zs"\ze[^,]

also if you have already defined your search term using / you can leave the search portion of the search replace empty and it will use the current search.

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