我正在使用vim编辑器,有一个包含HTML标记的大型文本文件。现在我需要将其准备成网页格式,并添加<p></p>
标记到未格式化的行中。以下是一个示例:
Paragraph text one one line [... more ... ]
Other paragraph text on the next line [... more ... ]
<h1>html element thrown in on its own line</h1>
More paragraph text [... more ... ]
<!-- some other element (always own line) -->
There is still more text!
我正在寻找一种方法来搜索不以<
字符开头的行,并为这些行添加开放和关闭的<p></p>
标记......因此,之后,我的文件类似于这样:
<p>Paragraph text one one line [... more ... ] </p>
<p>Other paragraph text on the next line [... more ... ] </p>
<h1>html element thrown in on its own line</h1>
<p>More paragraph text [... more ... ] </p>
<!-- some other element (always own line ) -->
<p>There is still more text! </p>
如何查找不以起始字符<
开头的行?
%s:^\([^>].*\)$:<p>\1</p>:g
命令,并且它会将段落标签添加到每一行(即使已经有标签的行)。快成功了…… - thornomad[^>]
应该是[^<]
。 - Nefrubyr