vim-easy-align *vim-easy-align* *easy-align* ========================================================================= A simple, easy-to-use Vim alignment plugin without too much ambition. Author: Junegunn Choi Source: https://github.com/junegunn/vim-easy-align EasyAlign *EasyAlign* ------------------------------------------------------------------------- vim-easy-align defines interactive `:EasyAlign` command in the visual mode. For convenience, it is advised that you define a mapping for triggering it in your `.vimrc`. vnoremap :EasyAlign With this mapping, you can align selected lines with a few keystrokes. 1. key to start interactive EasyAlign command 2. Optional Enter keys to switch justficiation mode (default: left) 3. Optional field number (default: 1) 1 Alignment around 1st delimiters 2 Alignment around 2nd delimiters ... * Alignment around all delimiters (recursive) - Alignment around the last delimieters -2 Alignment around the one before the last delimieters 4. Delimiter General alignment around whitespaces = Operators containing equals sign (=, ==, !=, +=, &&=, ...) : Suitable for formatting JSON or YAML . Multi-line method chaining , Multi-line method arguments. CSV. } Closing braces (Try using it with a negative field number) | Table markdown During the key sequence, key will toggle right-justification mode. Examples: = Alignment around 1st equals signs (and the likes) 2= Alignment around 2nd equals signs (and the likes) 3= Alignment around 3rd equals signs (and the likes) *= Alignment around all equals signs (and the likes) = Right-justified alignment around 1st equals signs Alignment around 1st whitespaces 2 Alignment around 2nd whitespaces - Alignment around the last whitespaces : Alignment around 1st colons -} Alignment around the last closing braces EasyAlignRight *EasyAlignRight* ------------------------------------------------------------------------- EasyAlignRight is the right-justified version of EasyAlign command. Partial alignment in blockwise-visual mode ------------------------------------------------------------------------- In blockwise-visual mode (`CTRL-V`), EasyAlign command aligns only the selected parts, instead of the whole lines in the range. Defining custom alignment rules *g:easy_align_delimiters* ------------------------------------------------------------------------- let g:easy_align_delimiters = { \ '/': { 'pattern': '//*' }, \ 'x': { \ 'pattern': '[xX]', \ 'margin_left': ' <<<', \ 'margin_right': '>>> ', \ 'stick_to_left': 0 \ } \ } Handling unmatched lines *g:easy_align_ignore_unmatched* ------------------------------------------------------------------------- EasyAlign by default ignores lines without the matching delimiters (except in right-justification mode). This is to ignore interleaved comments commonly found in code. For example, when aligning the following code, { # Quantity of apples apple: 1, # Quantity of bananas bananas: 2, # Quantity of grapefruits grapefruits: 3 } this is usually what we want. { # Quantity of apples apple: 1, # Quantity of bananas bananas: 2, # Quantity of grapefruits grapefruits: 3 } However, this default behavior is configurable. let g:easy_align_ignore_unmatched = 0 Then we get, { # Quantity of apples apple: 1, # Quantity of bananas bananas: 2, # Quantity of grapefruits grapefruits: 3 }