如何在 vi 中替换 EOL 之前的文本?

发布于 2024-10-17 09:45:56 字数 261 浏览 8 评论 0原文

我正在尝试在 vi 中进行替换搜索。通常:

:s/yes/no/gc

不合作。 “是”是该行的最后一段文字。如果我搜索的文本不是最后一个单词的一部分,则该命令有效。但以下各项似乎都不配合:

:s/ye/no/gc
:s/yesCTRLVCTRLM/noCTRLVCTRLM/gc

该文件是 DOS 格式 (EOL) 文件。

建议?

I'm trying to do a search in replace in vi. The usual:

:s/yes/no/gc

isn't cooperating. The "yes" is the last piece of text on the line. If I search for text isn't part of the last word the command works. But none of the following seem to be cooperating:

:s/ye/no/gc
:s/yesCTRLVCTRLM/noCTRLVCTRLM/gc

The file is a DOS formated (EOL) file.

Suggestions?

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

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

发布评论

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

评论(1

夏日落 2024-10-24 09:45:56

:s/yes$/no/gc 应该可以解决这个问题

$ 是代表行尾的字符。 ^ 代表行的开头。

:s/yes$/no/gc Should do the trick

$ is the character representing the end of the line. ^ would represent the start of the line.

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