align-regexp
può fare questo. Mark la regione, e quindi utilizzare:
C-uM-xalign-regexp
RET\(\s-+[0-9]*\)[0-9]
RET-1
RET4
RETy
che dovrebbe essere l'approccio più semplice.
(Edit: In realtà, non è nemmeno bisogno di separare tale cifra finale; \(\s-+[0-9]+\)
funziona altrettanto bene per la regexp.)
Vedi le istruzioni interattive e Chfalign-regexp
RET e la variabile align-rules-list
per ciò che effettivamente sta facendo.
La parte degno di nota è che specificando un numero negativo per il gruppo, align-regexp
imposta l'attributo justify
:
`justify'
It is possible with `regexp' and `group' to identify a
character group that contains more than just whitespace
characters. By default, any non-whitespace characters in
that group will also be deleted while aligning the
alignment character. However, if the `justify' attribute
is set to a non-nil value, only the initial whitespace
characters within that group will be deleted. This has
the effect of right-justifying the characters that remain,
and can be used for outdenting or just plain old right-
justification.
alternativa le varie opzioni tabella di modifica possono affrontare questo (es org, ses, tavola -capture/release), oppure potresti farlo con un pattern di sostituzione elisp.
ad es. Quanto segue dovrebbe fare più o meno quello che stai cercando, a condizione che il file stia già usando spazi per l'allineamento (puoi usare untabify
per rimuovere le schede se non lo sono), e che tutte le linee hanno la stessa lunghezza (cioè gli spazi finali sono necessario su alcune linee se la colonna finale è di lunghezza variabile).
C-M-%\([0-9]+\)\([[:space:]]+\)
RET\,(format (concat "%" (number-to-string (1- (length \&))) "d ") (string-to-number \1))
RET
org-mode e un tavolo? – Reactormonk
tabella-mode, org-mode non è necessario qui, anche se generalmente molto utile –
Alla fine preferisco una soluzione basata su 'rect' (http://stackoverflow.com/a/10916207/357313). –