Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to select a column of a table in emacs org mode

Tags:

emacs

org-mode

I can't find my way around copying a column, or a series of them, from a table.

The only solution I found so far is to copy the whole table and then delete the columns I don't need.

I suppose there must be another easier way for this. Maybe I am just too tired to realize how to do it.

like image 621
Quora Feans Avatar asked Feb 25 '14 00:02

Quora Feans


People also ask

How do I select a column in a table?

You can also click anywhere in the table column, and then press CTRL+SPACEBAR, or you can click the first cell in the table column, and then press CTRL+SHIFT+DOWN ARROW. Note: Pressing CTRL+SPACEBAR once selects the table column data; pressing CTRL+SPACEBAR twice selects the entire table column.

How do you make a table in Org mode?

The easiest way to create a table is to directly type the "|" character at the beginning of a line, or after any amount of white space. This will put you in the first field of an atomic table. Once you've finished editing this cell, you can jump to the next one by pressing TAB .

How do I enter Org Mode in Emacs?

Emacs does not actually understand you are editing an Org document, yet. To enable Org mode on your current document, type M-x org-mode which will enable the Org mode on the current document. Those are minuses, not underscores.


2 Answers

I think the easiest way would be to take advantage of emacs rectangles

  1. To create your rectangle, put your cursor at one of the corners of the rectangle you want to create.

  2. Use C-SPC, or whatever you have set-mark-command set to.

  3. Place your cursor at the diagonal corner of your rectangle.

  4. Use C-x r rr to copy the rectangle to the register named r

  5. Use C-x r ir to insert the rectangle that is being held in the register named r.

Following this process will copy and insert the columns that you want. You may need to repeat this process if the columns are not adjacent.

NOTE

I am using a bolded r to denote that this is technically a name of the register, and not some special input.

like image 188
Justin Wood Avatar answered Sep 28 '22 09:09

Justin Wood


If you specifically want to copy the column(s) into another org table (or indeed back into the original table), there's support for that.

See C-hf org-table-copy-region RET

It works much like the regular rectangle commands, so it's not a better interface for selecting the column; but the associated paste command is smart about what it does with the content.

like image 35
phils Avatar answered Sep 28 '22 09:09

phils