From: Nick Dokos <nicholas.dokos@hp.com>
To: Jonathan Arkell <jonathana@criticalmass.com>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>,
andrea Crotti <andrea.crotti.0@gmail.com>
Subject: Re: From formatted to table
Date: Tue, 29 Sep 2009 15:07:25 -0400 [thread overview]
Message-ID: <8707.1254251245@alphaville.usa.hp.com> (raw)
In-Reply-To: Message from Jonathan Arkell <jonathana@criticalmass.com> of "Tue, 29 Sep 2009 13:54:58 EDT." <7EA78739DB6FF044926304E83668BF8222EED2EB@brewer.cmass.criticalmass.com>
Jonathan Arkell <jonathana@criticalmass.com> 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: emacs-orgmode-bounces+jonathana=3Dcriticalmass.com@gnu.org [mailto:em=
> acs-orgmode-bounces+jonathana=3Dcriticalmass.com@gnu.org] On Behalf Of andr=
> ea Crotti
> Sent: September 29, 2009 8:49 AM
> To: emacs-orgmode@gnu.org
> 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
next prev parent reply other threads:[~2009-09-29 19:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-29 14:48 From formatted to table andrea Crotti
2009-09-29 17:54 ` Jonathan Arkell
2009-09-29 19:07 ` Nick Dokos [this message]
2009-09-29 18:21 ` Bernt Hansen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8707.1254251245@alphaville.usa.hp.com \
--to=nicholas.dokos@hp.com \
--cc=andrea.crotti.0@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=jonathana@criticalmass.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).