首页 > 解决方案 > SVG 文件:删除每个带有 vim 的对象和内容

问题描述

我有一个包含数千个对象的 SVG 文件,所有这些对象都是<text></text>or<path></path>类型。

我需要删除 SVG/XML 中的每个基于文本的对象,同时删除标签和标签各自的内容。文件非常大,我正在寻找单行解决方案。

标签: xmlobjectsvgvectorvim

解决方案


:%s/<text\(\n\|.\)\{-}<\/text>//g
:%s                                Substitute command, applied to every line.
   /                               Pattern begins after this character.
    <text                          Opening tag.
         \(\n\|.\)                 Matches carriage returns or any other character. 
                  \{-}             Matches previous atom zero or more times but as few as possible.
                      <\/text>     Closing tag.
                              //   Replace with nothing.
                                g  Apply substitution to every match on the line.

推荐阅读