This page is not available in every language. Missing translations are disabled in the language selector.

Quick reference

Vim EasyAlign Cheatsheet

A quick reference guide for junegunn/vim-easy-align plugin: delimiter alignment, regex patterns, interactive live mode, and margins.

· Published

vim-easy-align is a fast, flexible, and intuitive Vim alignment plugin by Junegunn Choi.

Command Mode

Align by Delimiters

:EasyAlign :       " Standard preset delimiters (\=:.,&#|)
:EasyAlign |
:EasyAlign \       " Backslash represents space

Align by Regular Expression

:EasyAlign /[:;]+/

Target Occurrences

:EasyAlign |       " Align by 1st '|' delimiter
:EasyAlign 3 |     " Align by 3rd '|' delimiter
:EasyAlign * |     " Align by all '|' delimiters on lines

Formatting Options

:EasyAlign * | l4r1

" Option breakdown:
" l4   - lN: left_margin (4 spaces to left of delimiter)
" r1   - rN: right_margin (1 space to right of delimiter)
" ar   - a[lrc]: text alignment (left, right, center)
" dr   - d[lrc]: delimiter alignment (left, right, center)

Examples

:EasyAlign = dr (Delimiter Right-Aligned)

apple    = 1
banana  += apple
cake   ||= banana

:EasyAlign : (Dictionaries & YAML)

url:      jdbc:mysql://localhost/test
database: test

:EasyAlign *| (Markdown Tables)

| Option    | Description                   |
| 1         | On 1st occurrence             |
| 2         | On 2nd occurrence             |

Interactive Mode

Keystroke Description
{Visual} Enter Start interactive alignment over selection
ga {motion} Start interactive alignment over text object (e.g. gaip)

Interactive Mode Controls

Key Action
Enter Toggle text alignment (left -> right -> center)
Ctrl-L 4 Enter Set left margin width
Ctrl-R 4 Enter Set right margin width
Down Reset margins to 0

Interactive Example

  • gaip Ctrl-L 4 Enter = : Align around = across the paragraph with 4 leading spaces.

References

Related topics