35

I have a table like this:

| Verse No | Verse      |
|          | <10>       |
|        1 | line1 li=> |
|        2 | line2 li=> |

I would like to view it as

| Verse No | Verse      |
|          | <10>       |
|        1 | line1 line |
|          | 1 line1    |
|        2 | line2 line |
|          | 2 line2    |

I am aware of C-c ` but that's not enough, I want to see all text simultaneously. Read only is OK if need be.

2

4 Answers 4

46

org-mode has 2 table formats, the default org-table and the other is table.el.

Cell wrapping is available for tables in table.el format.

Try this

  1. Remove the extra row with <10> so your table will look similar to the example below:

    | Verse No | Verse             |
    |        1 | Line1 Line1 Line1 |
    |        2 | Line2 Line2 Line2 |
    

    Tip: Add a blank line above and below the table. The blank lines should prevent a bug when converting the table with C-c ~. Thanks to @ComproPrasad for troubleshooting and providing the workaround.

  2. Place your cursor, a.k.a the point, inside updated table then type C-c ~ and answer y. The updated table should look similar to example below:

    +----------+-------------------+
    | Verse No | Verse             |
    +----------+-------------------+
    |        1 | Line1 Line1 Line1 |
    +----------+-------------------+
    |        2 | Line2 Line2 Line2 |
    +----------+-------------------+
    
  3. Place your cursor inside updated table then type C-c ' and a new window or frame will appear.

  4. Type M-x t-r-t and each table cell should be highlighted.

  5. Place your cursor inside second column and type C-c C-c < until the column is the desired width.

    Tip: Use the universal argument key binding C-u to quickly repeat this step. For example, If your cell is 500 characters and you want to adjust the width to 10 characters do C-u 490 C-c C-c < which will repeat C-c C-c < command 490 times.

  6. Type C-c ' to finish editing table. These steps should leave you with a similar to the example below:

    +----------+------+
    | Verse No | Verse|
    +----------+------+
    |        1 |Line1 |
    |          |Line1 |
    |          |Line1 |
    +----------+------+
    |        2 |Line2 |
    |          |Line2 |
    |          |Line2 |
    +----------+------+
    

Thanks for asking your question!
Hope that helped!


This answer tested using:
emacs version: GNU Emacs 25.2.1 (x86_64-unknown-cygwin, GTK+ Version 3.22.10)
org version: Org mode version 9.1.2

18
  • 4
    Step 4 is not needed (at least in current emacs v. 26). Pressing C-c ~ as the step 7 converts the table.el table back to editable org table.
    – Heikki
    Jan 17, 2018 at 7:44
  • 1
    is there an option to speed up step 5, say when I have 500 char of content and I want them wrapped to 10 chars?
    – user2740
    Jan 19, 2018 at 12:27
  • 2
    Made a video: youtu.be/Jo4RlPqs0_c Aug 6, 2018 at 20:27
  • 4
    what is step 4? Is t-r-t shorthand for another command? I've found that when dealing with tables that have text with embedded links, after step 3, only the column headings are selected, and I need a way to select each table cell, as in step 4. However, I don't know what step 4 is actually referring to, since M-x t-r-t shows nothing for me with org-mode 9.1.9
    – adamc
    Nov 14, 2018 at 0:50
  • 2
    @kotchwane - I understand your frustration. Other than C-c ', I'm not sure there are any default key bindings in org for table.el. I rarely use table.el because the format lacks many features compared to org-table. For example, AFAIK table.el tables can't be passed to src blocks. Is there a specific reason why you want use table.el besides column wrapping?
    – Melioratus
    Jun 4, 2020 at 17:08
12

Adjust Column Width with Wrap Around

Here is a solution adapted for org-mode 9.1.13, Spacemacs (0.200.13), emacs 26.1 for convenience.

Starting with the following content at a buffer in org-mode:


| Verse No | Verse             |
|        1 | Line1 Line1 Line1 |
|        2 | Line2 Line2 Line2 |

Note that you must leave a NEWLINE on top of the above table to avoid the bug of table.el.

  1. Convert the table to table.el format by C-c ~.
+----------+-------------------+
| Verse No | Verse             |
+----------+-------------------+
|        1 | Line1 Line1 Line1 |
+----------+-------------------+
|        2 | Line2 Line2 Line2 |
+----------+-------------------+
  1. Directly adjust the column width by SPC u 10 SPC SPC table-narrow-cell.
+----------+---------+
| Verse No | Verse   |
+----------+---------+
|        1 | Line1   |
|          |Line1    |
|          |Line1    |
+----------+---------+
|        2 | Line2   |
|          |Line2    |
|          |Line2    |
+----------+---------+
  1. Convert the table back to org-table format by C-c ~.
2
  • My newer spacemacs setup no longer works with the above solution. But I found that conventing to table.el format, then I can manually adjust the line wrap. After manual editing, then I can convert it back, and get the desired wraps.
    – Yu Shen
    Jul 23, 2019 at 18:14
  • 2
    SPC u 10 is not required. 10 auto-prefaces it to C-u 10- (Emacs 27.0.50, Spacemacs 9.0.)
    – Gavin
    Oct 7, 2019 at 15:20
8

Once you follow along the accepted answer and fixed the size of a long column in an existing table, toggling table-fixed-width-mode by M-x table-fixed-width-mode seems to do the trick of automatically wrapping (future) long lines of text in a column in table edit mode. You enter table edit mode by keying C-c '

Tested on: Emacs 25.2.2, Org-Mode 9.1.6

0

After trying tabel.el, as well as two MacOS apps called TableFlip and MarkupTable, I decided the best solution for me is to simply edit the table in Excel or Google Sheets, then copy-paste the contents onto this site to convert to org-mode table format:
https://tabletomarkdown.com/convert-spreadsheet-to-markdown/

1
  • With ChatGPT, it should be easy to create a csv2org.py script.
    – HappyFace
    Oct 11 at 0:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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