Here's a blow-by-blow account of the method I describe in the comments. We start with a table like this (it's better to have the spaces around each |
, so I just realigned your table above with TAB to get that):
| Col1 | Col2 | Col3 | | | |
| a | b | longer | data | with | spaces |
| a | b | another | bit | | |
Now place the cursor on the top |
character after "Col3", place the mark there with C-<space>
, move the cursor to the bottom row between the |
and the b
of "bit"., You have now marked a rectangle of width one character that includes the whole column of |
. Now kill the rectangle with C-x r k
. We end up with a table like this:
| Col1 | Col2 | Col3 | | |
| a | b | longer data | with | spaces |
| a | b | another bit | | |
Now lather, rinse, repeat: Place the cursor on the |
after "Col3", mark it with C-<space>
, move the cursor to the space after the |
in the same character column but on the bottom row of the table and kill that rectangle. You end up with this table:
| Col1 | Col2 | Col3 | |
| a | b | longer data with | spaces |
| a | b | another bit | |
Do the whole thing again with the remaining column of |
. You end up with this table:
| Col1 | Col2 | Col3 |
| a | b | longer data with spaces |
| a | b | another bit |
You can, if you want, squash multiple spaces into a single space: select the table as a region in the usual way (place the cursor at the beginning of the table, set the mark with C-<space>
, move the cursor to the end of the table) and then replace multiple spaces with a single space using a regexp: M-C-% <space><space>* RET <space> RET !
(where I've made the spaces explicit: when you type the command, just press the space bar every time you see ). The final !
says "replace all matches". That gives:
| Col1 | Col2 | Col3 |
| a | b | longer data with spaces |
| a | b | another bit |
Then realign the table with TAB and you are done:
| Col1 | Col2 | Col3 |
| a | b | longer data with spaces |
| a | b | another bit |
Once you have the keystrokes in your fingers, it goes fast. And although it's tedious for a table with many columns to be merged, it's not too bad. With only a little more effort, you can get a keyboard macro to do the rectangle killing, so all you have to do is move to the top |
and execute the macro (the squashing of spaces and the final alignment are still done separately at the end). Further automation is possible but more complicated, so I'll stop here.
org-table-merge
command that did what you want, that's what you should use. But I don't think there is, so I suggested the above manual method as a way forward.|
characters for the columns I want to merge using rectangular select. That works but is very tedious if you need to do 3+ columns, I was looking for a solution where I could just select a range of columns and use one set of commands to merge them.