Vim's macro functionality did this for me. First, I delimited each column of the table with a tab. Then, I just recorded a macro and executed it on each line:
qd (record macro to register "d") I (insert at beginning of line) <tr><td> (HTML markup for table row / table data) esc (return to edit mode) f<tab> (find the next tab) cl (change the character after the cursor) </td><td> (end one td element and start another) esc (return to edit mode) A (append at end of line) </td></tr> (end td and tr elements) esc (return to edit mode) j (down one line) q (terminate macro recording)
You could then optionally edit the macro to invoke itself recursively:
qD (append macro to register "d") @d (invoke macro "d") q (terminate macro recording)
@d
In Vim, this makes quick work of a bunch of tedious HTML edits:
Robots for the win!
On a side-note, I captured this GIF image using the screen capture utility I talked about here. Oddly, I see that instead of being surrounded by window trim, it is surrounded by the contents of the window behind it. A peculiarity of the Windows APIs? Maybe an inquiry for another post. Until then, happy hackin'.
No comments:
Post a Comment