我的文本文件中包含以下内容:
<Location>ame<Location>
<Title>Kill-A-Watt Meter<Title>
<Type>for sale by owner<Type>
<Category>electronics - by owner<Category>
<Email>youremail@gmail.com<Email>
<Street>My Street<Street>
我希望将每行中的第二个标签更改为结束html标签。例如,更改
<Location>ame<Location>
到
<Location>ame</Location>
在可视模式下选择了整个块之后,我尝试了:
:<>/s/[a-z]</[a-z]</
什么都没有发生。我在做什么错了?
答案 0 :(得分:2)
对于给定的文本,可能的替换是:
:'<,'>s/.*<\zs\.*/\\&
说明:
:'<,'>s use last selected visual area for substitution. More info in: help '<
/.*<\zs\.* match every character after the last '<'. More info in: help \zs
/\\& prepend matched text with a backslash. Here '&' means matched text. More info in: help s/\&