windows 10, emacs 26.1

Supose I have the following text:

OwnerKey    OrganizationName    GUID
111192    Infocom    41EA23423423423423423C8-62A61A1532C5
345423   TV    A3B8F234234234234239FA5-4D71242359EE
123423     TV    A3B823423423424234-234234234322659EE

I need to create something like this:

| OwnerKey | OrganizationName | GUID                                 |
|----------+------------------+--------------------------------------|
|   111192 | Infocom          | 41EA23423423423423423C8-62A61A1532C5 |
|   345423 | TV               | A3B8F234234234234239FA5-4D71242359EE |
|   123423 | TV               | A3B823423423424234-234234234322659EE |

How I can do this quickly. I don't want to do this manually line by line.

You find the Tbl menu at the right side of the Org menu. Mark the region you want to convert to an org-table and click on the menu item Tbl -> Convert Region.

The result is a table without header:

| OwnerKey | OrganizationName | GUID                                 |
|   111192 | Infocom          | 41EA23423423423423423C8-62A61A1532C5 |
|   345423 | TV               | A3B8F234234234234239FA5-4D71242359EE |
|   123423 | TV               | A3B823423423424234-234234234322659EE |

Adding the missing header is easy. Place point behind the first line Press RET for a newline and input the two characters |- and a tab. This adjusts the underlining of the header automagically.


You can use the minor mode orgtbl-mode also in buffers that are not in org-mode but in other major modes like text-mode.
Just call M-x orgtbl-mode RET and you get a new menu OrgTbl in the menu bar.
There you find the menu item Create or Convert bound to the key C-|. That works very similar to the above Convert Region.

It may be that you cannot insert the newline for the header underlining by just typing RET behind the first line. In that case type C-q C-j instead of RET to insert a newline.
Everything else works like for Convert Region above.

The really nice thing is that you even can insert #+TBLFM: lines below the table. Those lines work like in org-mode when you type C-c C-c on them.

  • This is possible only in org mode. But what about text mode? – Alexei Dec 1 at 16:15
  • @Alexei See my edit. – Tobias Dec 1 at 22:01

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.