Hi,
if you want to use a snippet for inserting cell by cell by pressing TAB you can try the attached tmCommand.
The command asks you about dimension of your table. Syntax is '4' for 4x4 or '3 5' for 3x5 or try '4 10 1' (1 := other style).
Best,
Hans
On 10.03.2007, at 07:06, Paul McCann wrote:
Yann B asked:
Is it doable? (I bet it is, but I can't figure it out). I want to create a HTML snippets that transforms a tab delimited table into an HTML table, fo instance, I'd select this:
item_01 item_02 item_03 item_11 item_12 item_13 item_21 item_22 item_23
hit a key combo, and get:
<table> <tr><th>item_01</th><th>item_02</th><th>item_03</th></tr> <tr><td>item_11</td><td>item_12</td><td>item_13</td></tr> <tr><td>item_21</td><td>item_22</td><td>item_23</td></tr> </table>
OK, I'm feeling sufficiently perverse to write it as a one-long- liner in perl (it's a *Saturday*...). Not elegant, to be sure, but it works OK and might give the "perl as unmaintainable line noise" folk a warm fuzzy feeling.
Cheers, Paul ====================================================================== =
Make a new command: input as "selected text", output as "replace selected text". The command should be:
#!/usr/bin/perl print "<table>\n\t<tr><td>",join("</td></tr>\n\t<tr><td>",map {chomp;join("</td><td>",(split(/\t/,$_)))} <>),"</td></tr>\n</table> \n";
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate