可视模式替代vscode vim

时间:2018-12-31 21:23:54

标签: vim visual-studio-code

我的文本文件中包含以下内容:

<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]</

什么都没有发生。我在做什么错了?

1 个答案:

答案 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/\&