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 ?
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.
Sign up to join this communityYes, that's possible:
Select lines you want to add to the table.
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:
With point (the cursor) on line1
, press C-o (org-open-line
), then enter C1
.
Press C-c - (org-ctrl-c-minus
) to insert the separator.
Let's say you have an empty table as shown below and you want to paste few lines in column C1.
|----+----|
| C0 | C1 |
|----+----|
| | |
|----+----|
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▮
|----+----|
| 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 |
|----+----|
| |▮ |
| | |
| | |
|----+----|
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 |
|----+-------|