GVIM 搜索和替换文本的问题
我们希望使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您只需要定义与
\zs
和\ze
匹配的开始和结束位置如果您已经使用
/
定义了搜索词, 您可以将搜索替换的搜索部分保留为空,它将使用当前搜索。you just need to define the start and end of you match with
\zs
and\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.