Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Splitting lines into fields in Emacs

Tags:

emacs

I have the following data

Food $44
Transport $52
Rentals $102
...

I want to transform to the following

Food      $44
Transport $52
Rentals   $102
...

Is there any in-built function in Emacs to do this? I'm not familiar with elisp. Thanks.

like image 913
Justin Wong Avatar asked Feb 23 '23 15:02

Justin Wong


2 Answers

Several possibilities. The easiest is probably C-u M-x align. See

http://www.emacswiki.org/emacs/AlignCommands

The other possibility is to use table-mode. Just do M-x table-capture, use one space as column and newline (C-q C-j) as row delimiter. Afterwards, you can use M-x table-release do get rid of the lines. For more information, see

http://www.emacswiki.org/emacs/TableMode

(and the Emacs manual, of course).

like image 77
pokita Avatar answered Mar 02 '23 16:03

pokita


One of the emacs align commands should do the job.

Start with C-u M-x align after selecting the region you want to line up.

like image 29
ObscureRobot Avatar answered Mar 02 '23 15:03

ObscureRobot