Skip to main content
  1. Entry/

align設定用例集

<pre class="code lang-c" data-lang="c">int count = 0;

float degree = 0.2;

<pre class="code">M-x align</pre>
<pre class="code lang-c" data-lang="c">int   count  = 0;

float degree = 0.2;

<pre class="code lang-lisp" data-lang="lisp">(add-to-list &#39;align-rules-list
         &#39;(hoge-assignment ; ルールの名前
           ; オプションをここに書く
           ))</pre>
<pre class="code">f| v align-rules-list</pre>
<pre class="code lang-lisp" data-lang="lisp">(add-to-list &#39;align-rules-list
         &#39;(atmark-assignment
           (regexp . &#34;\\( *\\)@&#34;)    ; 基準を定義する<a class="keyword" href="http://d.hatena.ne.jp/keyword/%C0%B5%B5%AC%C9%BD%B8%BD">正規表現</a>
           (modes  . &#39;(text-mode)))) ; ルールを適用するモード</pre>

<pre class="code">foo@bar

hoge@huga 1@2

<pre class="code">foo  @bar

hoge @huga 1 @2

<pre class="code lang-lisp" data-lang="lisp">(add-to-list &#39;align-rules-list
         &#39;(<a class="keyword" href="http://d.hatena.ne.jp/keyword/yaml">yaml</a>-assignment
           (regexp . &#34;:\\(\\s-*\\)&#34;) ; 末尾に \\(\\s-*\\)
           (modes  . &#39;(<a class="keyword" href="http://d.hatena.ne.jp/keyword/yaml">yaml</a>-mode))))</pre>

<pre class="code lang-yaml" data-lang="yaml">Winter:

Decemberde: 12 January: 1 February: 2

<pre class="code lang-yaml" data-lang="yaml">Winter:

Decemberde: 12 January: 1 February: 2

<pre class="code lang-lisp" data-lang="lisp">(add-to-list &#39;align-rules-list
         &#39;(camma-assignment
           (regexp . &#34;,\\( *\\)&#34;)
           (repeat . t)              ; 複数回適用を有効に
           (modes  . &#39;(<a class="keyword" href="http://d.hatena.ne.jp/keyword/perl">perl</a>-mode))))</pre>

<pre class="code">my @primes = (
1,2,3,5,7,
11,13,17,19,23,
29,31,37,41,43,

);

<pre class="code">my @primes = (
1,  2,  3,  5,  7,
11, 13, 17, 19, 23,
29, 31, 37, 41, 43,

);

<pre class="code lang-lisp" data-lang="lisp">(add-to-list &#39;align-rules-list
         &#39;(tab-stop-assignment
           (regexp   . &#34;\\(\\s-+\\)&#34;)
           (tab-stop . t)              ; タブ位置でそろえる
           (modes    . &#39;(text-mode))))</pre>
<pre class="code">0....5..8

yes はい no いいえ

<pre class="code">0....5..8

yes はい no いいえ

<pre class="code lang-lisp" data-lang="lisp">(add-to-list &#39;align-rules-list
         &#39;(column-assignment
           (regexp . &#34;\\(\\s-+\\)&#34;)
           (column . 10)            ; そろえる列数
           (modes . &#39;(text-mode))))</pre>

<pre class="code">0....5....10

english 英語 japanese 日本語 french フランス語

<pre class="code">0....5....10

english 英語 japanese 日本語 french フランス語

<pre class="code lang-lisp" data-lang="lisp">(add-to-list &#39;align-rules-list
         &#39;(custom-separete-assignment
           (regexp . &#34;,\\(\\s-*\\)&#34;)
           (separate . &#34;\\(===\\)&#34;)  ; 段落の切れ目
           (modes . &#39;(text-mode))))</pre>

<pre class="code">January, 1

February, 2 March, 3 #

April, 4 May, 5 June, 6

<pre class="code">January,  1

February, 2 March, 3 #

April, 4 May, 5 June, 6

<pre class="code">$ git diff -b</pre>
<pre class="code">; regexpだけを指定する場合

M-x align-regexp

; groupやrepeatなども指定する場合 C-u M-x align-regexp