This is not quite the answer, but here is how I did it:
Align with &, for example: Cx. & .
Select the entire column that I need with regular selection commands.
Cut a rectangular area using Cx rk .
This is not super automatic, but with some exercises it is not an obstacle, except, perhaps, if you need to reformat the old document and make many changes at once.
EDIT
(defun latex-merge-next-column (start end column) "Works on selected region, removes COLUMN'th ampersand in every line in the selected region" (interactive "r\nnColumn to merge: ") (labels ((%nth-index-of (line) (let ((i -1) (times 0)) (while (and (< times column) i) (setq i (position ?\& line :start (1+ i)) times (1+ times))) i))) (let ((region (split-string (buffer-substring start end) "\n")) amp-pos replacement) (dolist (line region) (setq amp-pos (%nth-index-of line) replacement (cons (if amp-pos (concat (subseq line 0 amp-pos) (subseq line (1+ amp-pos))) line) replacement))) (kill-region start end) (insert (mapconcat #'identity (reverse replacement) "\n")))))
This will work in the selected region and remove the nth ampersand in each line. You can associate it with a key convenient for you, say:
(global-set-key (kbd "Cc Cn") 'latex-merge-next-column)
Then Cc Cn 2 removes every second ampersand in the selected rows.
user797257
source share