From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: From formatted to table Date: Tue, 29 Sep 2009 15:07:25 -0400 Message-ID: <8707.1254251245@alphaville.usa.hp.com> References: <7EA78739DB6FF044926304E83668BF8222EED2EB@brewer.cmass.criticalmass.com> Reply-To: nicholas.dokos@hp.com Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Msi3f-0003AA-Lj for emacs-orgmode@gnu.org; Tue, 29 Sep 2009 15:08:19 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Msi3b-00037x-3Y for emacs-orgmode@gnu.org; Tue, 29 Sep 2009 15:08:19 -0400 Received: from [199.232.76.173] (port=42166 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Msi3a-00037p-Sy for emacs-orgmode@gnu.org; Tue, 29 Sep 2009 15:08:14 -0400 Received: from g1t0027.austin.hp.com ([15.216.28.34]:17246) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Msi3a-0002Li-9V for emacs-orgmode@gnu.org; Tue, 29 Sep 2009 15:08:14 -0400 In-Reply-To: Message from Jonathan Arkell of "Tue, 29 Sep 2009 13:54:58 EDT." <7EA78739DB6FF044926304E83668BF8222EED2EB@brewer.cmass.criticalmass.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Jonathan Arkell Cc: "emacs-orgmode@gnu.org" , andrea Crotti Jonathan Arkell 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