Tag Archives: vim

Vim tips and tricks: HTML table re-ordering

Suppose you have an HTML table on a static website, not dynamically created. It shows a grid of thumbnail photos in table cells. The code was something like the following:

<table>
 <tr>
 <td><a href="photo/photo01.html"><img src="photo/photo01.jpg" alt="" /></a></td>
 <td><a href="photo/photo02.html"><img src="photo/photo02.jpg" alt="" /></a></td>
 <td><a href="photo/photo03.html"><img src="photo/photo03.jpg" alt="" /></a></td>
 <td><a href="photo/photo04.html"><img src="photo/photo04.jpg" alt="" /></a></td>
 <td><a href="photo/photo05.html"><img src="photo/photo05.jpg" alt="" /></a></td>
 </tr>
 <tr>
 <td><a href="photo/photo06.html"><img src="photo/photo06.jpg" alt="" /></a></td>
 <td><a href="photo/photo07.html"><img src="photo/photo07.jpg" alt="" /></a></td>
 <td><a href="photo/photo08.html"><img src="photo/photo08.jpg" alt="" /></a></td>
 <td><a href="photo/photo09.html"><img src="photo/photo09.jpg" alt="" /></a></td>
 <td><a href="photo/photo10.html"><img src="photo/photo10.jpg" alt="" /></a></td>
 </tr>
 <!-- etc... -->
</table>

Yes, ouch!

There are hundreds of photos, spread over several pages in several HTML files, and you want to put them all on one page. You also want to change the number of columns of the thumbnail grid. How are you going to do this in the most efficient way possible, without turning the code into a dynamically generated code? Read on to learn more, using grep and vim!

Continue reading Vim tips and tricks: HTML table re-ordering