align-regexp
これを行うことができます。領域をマークしてから、次を使用します。
C-uM-x align-regexp
RET \(\s-+[0-9]*\)[0-9]
RET -1
RET 4
RET y
それが最も簡単なアプローチです。
(編集:実際、最後の桁を分離する必要さえありません\(\s-+[0-9]+\)
。正規表現でも同様に機能します。)
実際に何をしているかについては、インタラクティブなプロンプトと変数を参照してくださいC-hf align-regexp
RET。align-rules-list
注目すべき部分は、グループに負の数を指定することで、属性をalign-regexp
設定することです: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.
別の方法として、さまざまなテーブル編集オプション (org、ses、table-capture/release など) を使用するか、elisp 置換パターンを使用してこれを処理することもできます。
たとえば、ファイルがすでに整列のためにスペースを使用していて (untabify
そうでない場合はタブを削除するために使用できます)、すべての行が同じ長さである (つまり、末尾のスペースが最後の列が可変長の場合、一部の行で必要です)。
C-M-% \([0-9]+\)\([[:space:]]+\)
RET \,(format (concat "%" (number-to-string (1- (length \&))) "d ") (string-to-number \1))
RET