align-regexp
. Zaznaczyć region, a następnie za pomocą:
C UM xalign-regexp
RET\(\s-+[0-9]*\)[0-9]
RET-1
RET4
RETy
Powinno być najprostsze podejście.
(Edit: W rzeczywistości, nawet nie trzeba oddzielić że ostatecznym cyfry; \(\s-+[0-9]+\)
działa równie dobrze na regexp).
Zobacz interaktywne podpowiedzi i Chfalign-regexp
RET i zmienna align-rules-list
dla tego, co faktycznie robi.
godny uwagi jest to, że określając liczbę ujemną dla grupy, align-regexp
ustawia atrybut 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.
Alternatywnie różne opcje tabeli edycji mogą sobie z tym poradzić (np org, SES, stół -capture/release), lub możesz to zrobić z zastępczym wzorem zastępczym.
np. Poniższe powinny zrobić mniej więcej to, czego szukasz, pod warunkiem, że plik już używa spacji do wyrównania (możesz użyć untabify
, aby usunąć tabulacje, jeśli nie) i że wszystkie linie mają tę samą długość (tj. Końcowe spacje są potrzebne w niektórych liniach, jeśli ostatnia kolumna ma różną długość).
C M-%\([0-9]+\)\([[:space:]]+\)
RET\,(format (concat "%" (number-to-string (1- (length \&))) "d ") (string-to-number \1))
RET
org i trybu tabeli? – Reactormonk
Tryb tabelowy, tryb org nie jest tutaj konieczny, ale ogólnie bardzo przydatny –
Na koniec wolę rozwiązanie oparte na 'rect' (http://stackoverflow.com/a/10916207/357313). –