xuansamdinh
xuansamdinh

Reputation: 243

Edit text in tag to become a new tag

I have some html file has contents which looks like this:

<tr>
  <td class="col12">3</td>
  <td class="col13"></td>
  <td class="col14">1407664073.4287</td>
  <td class="col15">OUT401-20140810-164753-1407664073.4287.wav</td>
</tr>

That is a table with many raws and collumns. And I want to change every class="col15"collumn to:

<td class="col15"><a href="OUT401-20140810-164753-1407664073.4287.wav">OUT401-20140810-164753-1407664073.4287.wav</a></td>

It means changing the text in this collumn to a hyperlink.

How can I do this in an effectively and repetitively way? A macro, or strick?

I use Sublime Text with Vintage, Emmet, and try to record a macro like this:

qa
/col15
cit
a<Tab><Esc>p
2l
p
a</
<Esc>

The problem is, then I type q again to stop recoding macro a, and type some command such as n, i,.. Vintage notifies that a another macro is being recoding. So when a macro was stopped? And as a result, the a macro does not work as I expected.

I aslo tried to do this in Vim with same procedure, but got no better result.

Did I do some wrong step or what? Please give me some advice! Thank you!

Upvotes: 1

Views: 72

Answers (1)

romainl
romainl

Reputation: 196751

A possible "vanilla" Vim way:

:g/col15/norm cit<a href="^R"">^R"</a>

^R is obtained with <C-v><C-r>.

See :help :g, :help :normal, :help registers and :help navigation.

I have no idea if that can be done with ST's vintage mode, though.

Upvotes: 4

Related Questions