I\'ve read in several places that the rectangle functions in emacs are very useful. I\'ve read a bit about them, and I can\'t quite figure why. I mean, when you want to kill
If you have data in columns in a text file with M-x delete-rectangle
or M-x kill-rectangle
you can delete a single column of data. Similarly, M-x yank-rectangle
will paste in a column of text.
For example, take the following text:
1. alligator alphorn
2. baboon bugle
3. crocodile cornet
4. dog didgeridoo
5. elephant euphonium
6. fish flugelhorn
7. gopher guitar
Select from the a of alligator to the g of guitar. The beginning and end of the selection mark out two opposite corners of the rectangle. Enter M-x kill-rectangle
and you immediately have:
1. alphorn
2. bugle
3. cornet
4. didgeridoo
5. euphonium
6. flugelhorn
7. guitar
Next put the mark at the end of the top line, add a few spaces if required and enter M-x yank-rectangle
and ta-da! You have re-ordered the columns:
1. alphorn alligator
2. bugle baboon
3. cornet crocodile
4. didgeridoo dog
5. euphonium elephant
6. flugelhorn fish
7. guitar gopher