开发者

How can I replace text just before the EOL in vi?

开发者 https://www.devze.com 2023-02-10 20:11 出处:网络
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 o开发者_如何学Cn the line.If I search for text isn\'t part of the last w

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 o开发者_如何学Cn 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?


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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号