Tip 1319 Printable Monobook Previous Next
created September 4, 2006 · complexity basic · author Sérgio Luiz Araújo Silva · version 6.0
Suppose you have a table of numbers like:
1 12 3 13 11 55 67 1 12 3 13 11 55 67 1 12 3 13 11 55 67 1 12 3 13 11 55 67 1 12 3 13 11 55 67
To generate html tags of form 1 use command:
:%s/\(\s\+\)\(\d\+\)/<td>\2<\/td>/g
The result:
<td>1</td><td>12</td><td>3</td><td>13</td><td>11</td><td>55</td><td>67</td> <td>1</td><td>12</td><td>3</td><td>13</td><td>11</td><td>55</td><td>67</td> <td>1</td><td>12</td><td>3</td><td>13</td><td>11</td><td>55</td><td>67</td> <td>1</td><td>12</td><td>3</td><td>13</td><td>11</td><td>55</td><td>67</td> <td>1</td><td>12</td><td>3</td><td>13</td><td>11</td><td>55</td><td>67</td>
To generate words like:
<td>uma</td><td>porção</td><td>de</td><td>palavras</td><td>para</td><td>testes</td><td>deve</td> <td>ser</td><td>digitada</td><td>após</td><td>isto</td><td>coloque</td><td>espaço</td><td>no</td> <td>inicio</td><td>de</td><td>cada</td><td>linha</td>
use commands:
:%s/^/ /g :%s/\(\s\+\)\(\S\+\)/<td>\2<\/td>/g
Comments[]
:%s,\(\d\+\),<td>\1</td>,g