In Emacs, you can not only select by lines, but also by columns. If you select by columns, the selection is called a rectangle. You can use rectangles with the following shortcuts:
- C-@ or C-Space — start selection (as usual)
- M-x delete-rectangle or C-x r d — delete the rectangle delimited by the start selection and the current cursor position
- M-x kill-rectangle or C-x r k — then you can use — M-x yank-rectangle or C-x r y
- M-x clear-rectangle or C-x r c — replace the contents of the rectangle with spaces
- M-x open-rectangle or C-x r o — insert spaces in the area and push the original contents to the right