Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The other answers here are great, especially @nelstrom's comment for Tabular.vim and his excellent screencast.</p> <p>But if I were feeling too lazy to install any Vim plugins, yet somehow willing to use Vim macros, I'd use macros.</p> <p>The algorithm:</p> <pre><code>For each line, Add tons of spaces before the symbol = Go to the column you want to align to Delete all text up to =, thereby shifting the = into the spot you want. </code></pre> <p>For your example,</p> <pre><code>foo = rhs.foo; foobar = rhs.foobar; bar = rhs.bar; toto = rhs.toto; </code></pre> <p>Position the cursor anywhere on the first line and record the macro for that line by typing, in normal mode:</p> <pre><code>qa0f=100i &lt;Esc&gt;8|dwjq </code></pre> <p>Which translates to:</p> <ol> <li><code>qa</code> -- Record a macro in hotkey <code>a</code></li> <li><code>0</code> -- Go to the beginning of the line</li> <li><code>f=</code> -- Go to the first equals sign</li> <li><code>100i &lt;Esc&gt;</code> -- (There's a single space after the <code>i</code>, and the <code>&lt;Esc&gt;</code> means press escape, don't type "&lt;Esc&gt;".) Insert 100 spaces</li> <li><code>8|</code> -- Go to the 8th column (sorry, you'll have to manually figure out which column to align to)</li> <li><code>dw</code> -- Delete until the next non-space character</li> <li><code>j</code> -- Go to the next line</li> <li><code>q</code> -- Stop recording.</li> </ol> <p>Then run the macro stored at hotkey <code>a</code>, 3 times (for the 3 remaining lines), by putting the cursor on the second line and pressing:</p> <pre><code>3@a </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload