[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Orgmode] From formatted to table
From: |
Nick Dokos |
Subject: |
Re: [Orgmode] From formatted to table |
Date: |
Tue, 29 Sep 2009 15:07:25 -0400 |
Jonathan Arkell <address@hidden> wrote:
> I do a macros for this
>
> Put the point on the first word of the table
> Record Macro
> Search for " "
> Insert "|"
> Tab (next column)
> Tab (first column next row
> Stop Recording.
>
> Then just C-x e (run macro) until the job is done. If you know how many l=
> ines are on the table, you can use a prefix argument with C-x e.
>
>
>
> -----Original Message-----
> From: address@hidden [mailto:em=
> address@hidden On Behalf Of andr=
> ea Crotti
> Sent: September 29, 2009 8:49 AM
> To: address@hidden
> Subject: [Orgmode] From formatted to table
>
> I have for example a table where
>
> | one thing | dsjfls |
> | two things | dslkjfls |
> | three abc dej | dsf |
>
> And I would like to get
>
> | one | thing | dsjfls |
> | two | things | dslkjfls |
> | three | abc dej | dsf |
>
> I tried some simple substitutions but substituting all the spaces in
> the region selected will cause problems elsewhere. I would need to
> substitute " " only in one column, is that possible?
>
>
Two things to add to Jonathan's answer:
o You don't have to know the length of the table: just mark the region
containing the table, C-x n n (narrow-to-region) and C-0 C-x e to repeat
the macro for ever or until an error occurs, whichever comes first :-)
Then widen: C-x n w
o Alternatively, "It's just text" (TM), so you can use a
sed/perl/awk/python/foo script to do arbitrary
transformations. Blasphemy, I know, but emacs doesn't have to do
everything.
You can even run the script from within emacs: mark the region and C-u
M-| (shell-command-on-region with the prefix argument specifying that
that output of the command is to replace the region) with the following
script
sed '/|/s/[^|] /&| /'
should do the trick. It's utterly liberating to be able to use all sorts
of different tools on your file and the single, most important advantage
of org-mode when compared to all the other systems out there.
HTH,
Nick