user1592380
user1592380

Reputation: 36267

visual mode substitiute in vscode vim

I have the following in a text file:

<Location>ame<Location>
<Title>Kill-A-Watt Meter<Title>
<Type>for sale by owner<Type>
<Category>electronics - by owner<Category>
<Email>[email protected]<Email>
<Street>My Street<Street>

I ant to change the second tags in each line to closing html tags. eg change

<Location>ame<Location>

to

<Location>ame</Location>

After selecting the entire block in visual mode I tried:

:<>/s/[a-z]</[a-z]</

Nothing is happening. What am I doing wrong?

Upvotes: 0

Views: 57

Answers (1)

builder-7000
builder-7000

Reputation: 7627

For the given text a possible substitution is:

:'<,'>s/.*<\zs\.*/\\&

explanation:

:'<,'>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/\&

Upvotes: 2

Related Questions