在vim中,我想用文字字符串替换换行符\n
。
例如,如果我打开一个包含以下文本的文件:
This is line one
This is line two
我要替换换行符,并具有以下内容:
This is line one\nThis is line two
我怎样才能做到这一点?
您必须使用来逃避替换的替换部分 \
:1,$-1s/\n/\\n
分解
: start an ex command
1,$-1 over a range from the first line till the last but one
s/ substitute
\n all newlines
/ with
\\n literal string \n
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句