6

Here is my question, I have multiple lines of text, line this:

line1
line2
line3
...

And I want to create a org-mode table like this:

| C1    |
|-------|
| line1 |
| line2 |
| line3 | 
| ....  |

Is it possible ?

10

Yes, that's possible:

  1. Select lines you want to add to the table.

  2. Press C-c | (org-table-create-or-convert-from-region). This will give you:

    | line1 |
    | line2 |
    | line3 |
    

Now all you need to do is add the header line. Here's one way of doing that:

  1. With point (the cursor) on line1, press C-o (org-open-line), then enter C1.

  2. Press C-c - (org-ctrl-c-minus) to insert the separator.

5

Let's say you have an empty table as shown below and you want to paste few lines in column C1.

|----+----|
| C0 | C1 |
|----+----|
|    |    |
|----+----|

Step 1: Copy the lines as a rectangle

Copy the lines using copy-rectangle-as-kill (C-x r M-w) or cut them using kill-rectangle (C-x r k). Below shows the point and mark locations I used when copying/cutting the rectangle.

▯ine1
line2
line3▮

Step 2: Make space for the lines to be inserted in the table

|----+----|
| C0 | C1 |
|----+----|
|    |▮   |
|----+----|

With the cursor in the desired column as shown above, call org-open-line for the required number of times. For this example, we'll call it twice.

|----+----|
| C0 | C1 |
|----+----|
|    |▮   |
|    |    |
|    |    |
|----+----|

Step 3: Paste the rectangle

Paste the rectangle using M-x yank-rectangle or C-x r y. That will give you:

|----+----|
| C0 | C1 |
|----+----|
|    |line1    |
|    |line2    |
|    |line3    |
|----+----|

Hit C-c C-c to auto align the table.

|----+-------|
| C0 | C1    |
|----+-------|
|    | line1 |
|    | line2 |
|    | line3 |
|----+-------|
  • This solution worked better for me because my lines had org dates in them. – Tedward Jul 18 '17 at 16:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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