免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 5041 | 回复: 5
打印 上一主题 下一主题

在 vi 中如何搜索换行符? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-11-21 12:43 |只看该作者 |倒序浏览
10可用积分
我想在 vi 编辑器中将全部换行符替换为 x。%s/\n/x 或者 %s/^n/x 都不行,在命令行用 sed 也不行。但我在网上搜索的格式是这样的。请问在 BSD 下面应如何操作?
谢谢

最佳答案

查看完整内容

Oh, sorry, i did a mistake that the "1,$s/\n/x/g" works in VIM.in VI, use "1,$s/$/x/g", works well.

论坛徽章:
0
2 [报告]
发表于 2007-11-21 12:43 |只看该作者
Oh, sorry, i did a mistake that the "1,$s/\n/x/g" works in VIM.
in VI, use "1,$s/$/x/g", works well.

论坛徽章:
0
3 [报告]
发表于 2007-11-21 13:17 |只看该作者
You did a wrong operation, the replacement command in VI is:
[line_begin],[line_end]s/[org_content]/[new_content]/[suffix]

if you want to make all "EndLine" changed into "x", it will be:
1,$s/\n/x/g
here, the applying region is all content, (from line 1 to the end);
to change any "EndLine(\n)" into character "x";
and globally do this mission(g), not just change only the first matched one.

论坛徽章:
0
4 [报告]
发表于 2007-11-21 13:25 |只看该作者
/
:em11: :em11: :em11: :em11:

论坛徽章:
0
5 [报告]
发表于 2007-11-24 19:18 |只看该作者
原帖由 jefferic 于 2007-11-21 13:17 发表
You did a wrong operation, the replacement command in VI is:
[line_begin],[line_end]s/[org_content]/[new_content]/[suffix]

if you want to make all "EndLine" changed into "x", it will be:
1,$ ...


No match found.
除\n之外,其他都找不到。

论坛徽章:
0
6 [报告]
发表于 2007-11-24 23:10 |只看该作者
shell可以做到.你去shell版学下命令
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP