mirror of
https://github.com/junegunn/vim-easy-align.git
synced 2025-11-09 10:23:49 -05:00
Change option name and shorthand notations
- `mode_sequence` (`ms`) -> `align` (`a`) - `stick_to_left` (`<` / `s01`) This commit does not break backward compatibility. `mode_sequence` is still allowed.
This commit is contained in:
80
README.md
80
README.md
@@ -170,20 +170,20 @@ You can override these default rules or define your own rules with
|
||||
|
||||
#### Examples
|
||||
|
||||
| With visual map | Description | Equivalent command |
|
||||
| ------------------- | ---------------------------------- | ---------------------- |
|
||||
| `<Enter><Space>` | Around 1st whitespaces | `:'<,'>EasyAlign\ ` |
|
||||
| `<Enter>2<Space>` | Around 2nd whitespaces | `:'<,'>EasyAlign2\ ` |
|
||||
| `<Enter>-<Space>` | Around the last whitespaces | `:'<,'>EasyAlign-\ ` |
|
||||
| `<Enter>-2<Space>` | Around the 2nd to last whitespaces | `:'<,'>EasyAlign-2\ ` |
|
||||
| `<Enter>:` | Around 1st colon (`key: value`) | `:'<,'>EasyAlign:` |
|
||||
| `<Enter><Right>:` | Around 1st colon (`key : value`) | `:'<,'>EasyAlign:s0l1` |
|
||||
| `<Enter>=` | Around 1st operators with = | `:'<,'>EasyAlign=` |
|
||||
| `<Enter>3=` | Around 3rd operators with = | `:'<,'>EasyAlign3=` |
|
||||
| `<Enter>*=` | Around all operators with = | `:'<,'>EasyAlign*=` |
|
||||
| `<Enter>**=` | Left-right alternating around = | `:'<,'>EasyAlign**=` |
|
||||
| `<Enter><Enter>=` | Right alignment around 1st = | `:'<,'>EasyAlign!=` |
|
||||
| `<Enter><Enter>**=` | Right-left alternating around = | `:'<,'>EasyAlign!**=` |
|
||||
| With visual map | Description | Equivalent command |
|
||||
| ------------------- | ---------------------------------- | --------------------- |
|
||||
| `<Enter><Space>` | Around 1st whitespaces | `:'<,'>EasyAlign\ ` |
|
||||
| `<Enter>2<Space>` | Around 2nd whitespaces | `:'<,'>EasyAlign2\ ` |
|
||||
| `<Enter>-<Space>` | Around the last whitespaces | `:'<,'>EasyAlign-\ ` |
|
||||
| `<Enter>-2<Space>` | Around the 2nd to last whitespaces | `:'<,'>EasyAlign-2\ ` |
|
||||
| `<Enter>:` | Around 1st colon (`key: value`) | `:'<,'>EasyAlign:` |
|
||||
| `<Enter><Right>:` | Around 1st colon (`key : value`) | `:'<,'>EasyAlign:<l1` |
|
||||
| `<Enter>=` | Around 1st operators with = | `:'<,'>EasyAlign=` |
|
||||
| `<Enter>3=` | Around 3rd operators with = | `:'<,'>EasyAlign3=` |
|
||||
| `<Enter>*=` | Around all operators with = | `:'<,'>EasyAlign*=` |
|
||||
| `<Enter>**=` | Left-right alternating around = | `:'<,'>EasyAlign**=` |
|
||||
| `<Enter><Enter>=` | Right alignment around 1st = | `:'<,'>EasyAlign!=` |
|
||||
| `<Enter><Enter>**=` | Right-left alternating around = | `:'<,'>EasyAlign!**=` |
|
||||
|
||||
#### Using regular expressions
|
||||
|
||||
@@ -211,7 +211,7 @@ keys listed below. The meaning of each option will be described in
|
||||
| `CTRL-D` | `delimiter_align` | left, center, right |
|
||||
| `CTRL-U` | `ignore_unmatched` | 0, 1 |
|
||||
| `CTRL-G` | `ignore_groups` | [], ['String'], ['Comment'], ['String', 'Comment'] |
|
||||
| `CTRL-O` | `mode_sequence` | Input string (`/[lrc]+\*{0,2}/`) |
|
||||
| `CTRL-A` | `align` | Input string (`/[lrc]+\*{0,2}/`) |
|
||||
| `<Left>` | `stick_to_left` | `{ 'stick_to_left': 1, 'left_margin': 0 }` |
|
||||
| `<Right>` | `stick_to_left` | `{ 'stick_to_left': 0, 'left_margin': 1 }` |
|
||||
| `<Down>` | `*_margin` | `{ 'left_margin': 0, 'right_margin': 0 }` |
|
||||
@@ -275,21 +275,21 @@ You can even omit spaces between the arguments, so concisely (or cryptically):
|
||||
Nice. But let's make it even shorter. Option values can be written in shorthand
|
||||
notation.
|
||||
|
||||
- `:EasyAlign*/[:;]\+/s1l0`
|
||||
- `:EasyAlign*/[:;]\+/<l0`
|
||||
|
||||
The following table summarizes the shorthand notation.
|
||||
|
||||
| Option | Expression |
|
||||
| ------------------ | ---------- |
|
||||
| `filter` | `[gv]/.*/` |
|
||||
| `left_margin` | `l[0-9]+` |
|
||||
| `right_margin` | `r[0-9]+` |
|
||||
| `stick_to_left` | `s[01]` |
|
||||
| `ignore_unmatched` | `iu[01]` |
|
||||
| `ignore_groups` | `ig\[.*\]` |
|
||||
| `delimiter_align` | `d[lrc]` |
|
||||
| `mode_sequence` | `m[lrc*]*` |
|
||||
| `indentation` | `i[ksdn]` |
|
||||
| Option | Expression |
|
||||
| ------------------ | -------------- |
|
||||
| `filter` | `[gv]/.*/` |
|
||||
| `left_margin` | `l[0-9]+` |
|
||||
| `right_margin` | `r[0-9]+` |
|
||||
| `stick_to_left` | `<` or `s[01]` |
|
||||
| `ignore_unmatched` | `iu[01]` |
|
||||
| `ignore_groups` | `ig\[.*\]` |
|
||||
| `align` | `a[lrc*]*` |
|
||||
| `delimiter_align` | `d[lrc]` |
|
||||
| `indentation` | `i[ksdn]` |
|
||||
|
||||
For your information, the same operation can be done in interactive mode as
|
||||
follows:
|
||||
@@ -345,7 +345,7 @@ Alignment options
|
||||
| `ignore_unmatched` | boolean | 1 | Whether to ignore lines without matching delimiter |
|
||||
| `indentation` | string | `k` | Indentation method (*k*eep, *d*eep, *s*hallow, *n*one) |
|
||||
| `delimiter_align` | string | `r` | Determines how to align delimiters of different lengths |
|
||||
| `mode_sequence` | string | | Alignment modes for multiple occurrences of delimiters |
|
||||
| `align` | string | | Alignment modes for multiple occurrences of delimiters |
|
||||
|
||||
There are 4 ways to set alignment options (from lowest precedence to highest):
|
||||
|
||||
@@ -364,7 +364,7 @@ There are 4 ways to set alignment options (from lowest precedence to highest):
|
||||
| `ignore_unmatched` | `CTRL-U` | `iu[01]` | `g:easy_align_ignore_unmatched` |
|
||||
| `indentation` | `CTRL-I` | `i[ksdn]` | `g:easy_align_indentation` |
|
||||
| `delimiter_align` | `CTRL-D` | `d[lrc]` | `g:easy_align_delimiter_align` |
|
||||
| `mode_sequence` | `CTRL-O` | `m[lrc*]*` | |
|
||||
| `align` | `CTRL-A` | `m[lrc*]*` | |
|
||||
|
||||
### Filtering lines
|
||||
|
||||
@@ -626,38 +626,38 @@ To recap:
|
||||
:EasyAlign! **=
|
||||
```
|
||||
|
||||
In addition to these, you can fine-tune alignments over multiple occurrences of
|
||||
the delimiters with 'mode_sequence' option. (The option can also be set
|
||||
in interactive mode with the special key `CTRL-O`)
|
||||
In addition to these, you can fine-tune alignments over multiple occurrences
|
||||
of the delimiters with 'align' option. (The option can also be set in
|
||||
interactive mode with the special key `CTRL-A`)
|
||||
|
||||
```vim
|
||||
" Left alignment over the first two occurrences of delimiters
|
||||
:EasyAlign = { 'mode_sequence': 'll' }
|
||||
:EasyAlign = { 'align': 'll' }
|
||||
|
||||
" Right, left, center alignment over the 1st to 3rd occurrences of delimiters
|
||||
:EasyAlign = { 'm': 'rlc' }
|
||||
:EasyAlign = { 'a': 'rlc' }
|
||||
|
||||
" Using shorthand notation
|
||||
:EasyAlign = mrlc
|
||||
:EasyAlign = arlc
|
||||
|
||||
" Right, left, center alignment over the 2nd to 4th occurrences of delimiters
|
||||
:EasyAlign 2=mrlc
|
||||
:EasyAlign 2=arlc
|
||||
|
||||
" (*) Repeating alignments (default: l, r, or c)
|
||||
" Right, left, center, center, center, center, ...
|
||||
:EasyAlign *=mrlc
|
||||
:EasyAlign *=arlc
|
||||
|
||||
" (**) Alternating alignments (default: lr or rl)
|
||||
" Right, left, center, right, left, center, ...
|
||||
:EasyAlign **=mrlc
|
||||
:EasyAlign **=arlc
|
||||
|
||||
" Right, left, center, center, center, ... repeating alignment
|
||||
" over the 3rd to the last occurrences of delimiters
|
||||
:EasyAlign 3=mrlc*
|
||||
:EasyAlign 3=arlc*
|
||||
|
||||
" Right, left, center, right, left, center, ... alternating alignment
|
||||
" over the 3rd to the last occurrences of delimiters
|
||||
:EasyAlign 3=mrlc**
|
||||
:EasyAlign 3=arlc**
|
||||
```
|
||||
|
||||
### Extending alignment rules
|
||||
|
||||
@@ -51,7 +51,8 @@ let s:known_options = {
|
||||
\ 'margin_left': [0, 1], 'margin_right': [0, 1], 'stick_to_left': [0],
|
||||
\ 'left_margin': [0, 1], 'right_margin': [0, 1], 'indentation': [1],
|
||||
\ 'ignore_groups': [3 ], 'ignore_unmatched': [0 ], 'delimiter_align': [1],
|
||||
\ 'mode_sequence': [1 ], 'ignores': [3], 'filter': [1]
|
||||
\ 'mode_sequence': [1 ], 'ignores': [3], 'filter': [1],
|
||||
\ 'align': [1 ]
|
||||
\ }
|
||||
|
||||
let s:option_values = {
|
||||
@@ -65,7 +66,8 @@ let s:shorthand = {
|
||||
\ 'margin_left': 'lm', 'margin_right': 'rm', 'stick_to_left': 'stl',
|
||||
\ 'left_margin': 'lm', 'right_margin': 'rm', 'indentation': 'idt',
|
||||
\ 'ignore_groups': 'ig', 'ignore_unmatched': 'iu', 'delimiter_align': 'da',
|
||||
\ 'mode_sequence': 'm', 'ignores': 'ig', 'filter': 'f'
|
||||
\ 'mode_sequence': 'a', 'ignores': 'ig', 'filter': 'f',
|
||||
\ 'align': 'a'
|
||||
\ }
|
||||
|
||||
if exists("*strdisplaywidth")
|
||||
@@ -227,8 +229,9 @@ function! s:normalize_options(opts)
|
||||
let v = a:opts[k]
|
||||
let k = s:fuzzy_lu(k)
|
||||
" Backward-compatibility
|
||||
if k == 'margin_left' | let k = 'left_margin' | endif
|
||||
if k == 'margin_right' | let k = 'right_margin' | endif
|
||||
if k == 'margin_left' | let k = 'left_margin' | endif
|
||||
if k == 'margin_right' | let k = 'right_margin' | endif
|
||||
if k == 'mode_sequence' | let k = 'align' | endif
|
||||
let ret[k] = v
|
||||
unlet v
|
||||
endfor
|
||||
@@ -668,7 +671,7 @@ function! s:interactive(range, modes, n, d, opts, rules, vis, live)
|
||||
endif
|
||||
elseif c == 13 " Enter key
|
||||
let mode = s:shift(a:modes, 1)
|
||||
if has_key(opts, 'm')
|
||||
if has_key(opts, 'a')
|
||||
let opts.m = mode . strpart(opts.m, 1)
|
||||
endif
|
||||
elseif ch == '-'
|
||||
@@ -723,15 +726,15 @@ function! s:interactive(range, modes, n, d, opts, rules, vis, live)
|
||||
silent! call remove(opts, 'stl')
|
||||
silent! call remove(opts, 'lm')
|
||||
silent! call remove(opts, 'rm')
|
||||
elseif ch == "\<C-O>"
|
||||
let modes = tolower(s:input("Mode sequence: ", get(opts, 'm', mode), a:vis))
|
||||
elseif ch == "\<C-A>" || ch == "\<C-O>"
|
||||
let modes = tolower(s:input("Alignment ([lrc...][[*]*]): ", get(opts, 'a', mode), a:vis))
|
||||
if match(modes, '^[lrc]\+\*\{0,2}$') != -1
|
||||
let opts['m'] = modes
|
||||
let opts['a'] = modes
|
||||
let mode = modes[0]
|
||||
while mode != s:shift(a:modes, 1)
|
||||
endwhile
|
||||
else
|
||||
silent! call remove(opts, 'm')
|
||||
silent! call remove(opts, 'a')
|
||||
endif
|
||||
elseif ch == "\<C-_>" || ch == "\<C-X>"
|
||||
if a:live && regx && !empty(d)
|
||||
@@ -811,8 +814,8 @@ endfunction
|
||||
|
||||
let s:shorthand_regex =
|
||||
\ '\s*\%('
|
||||
\ .'\(lm\?[0-9]\+\)\|\(rm\?[0-9]\+\)\|\(iu[01]\)\|\(s\%(tl\)\?[01]\)\|'
|
||||
\ .'\(da\?[clr]\)\|\(ms\?[lrc*]\+\)\|\(i\%(dt\)\?[kdsn]\)\|\([gv]/.*/\)\|\(ig\[.*\]\)'
|
||||
\ .'\(lm\?[0-9]\+\)\|\(rm\?[0-9]\+\)\|\(iu[01]\)\|\(\%(s\%(tl\)\?[01]\)\|<\)\|'
|
||||
\ .'\(da\?[clr]\)\|\(\%(ms\?\|a\)[lrc*]\+\)\|\(i\%(dt\)\?[kdsn]\)\|\([gv]/.*/\)\|\(ig\[.*\]\)'
|
||||
\ .'\)\+\s*$'
|
||||
|
||||
function! s:parse_shorthand_opts(expr)
|
||||
@@ -828,7 +831,7 @@ function! s:parse_shorthand_opts(expr)
|
||||
let match = matchlist(expr, regex)
|
||||
if empty(match) | break | endif
|
||||
for m in filter(match[ 1 : -1 ], '!empty(v:val)')
|
||||
for key in ['lm', 'rm', 'l', 'r', 'stl', 's', 'iu', 'da', 'd', 'ms', 'm', 'ig', 'i', 'g', 'v']
|
||||
for key in ['lm', 'rm', 'l', 'r', 'stl', 's', '<', 'iu', 'da', 'd', 'ms', 'm', 'ig', 'i', 'g', 'v', 'a']
|
||||
if stridx(tolower(m), key) == 0
|
||||
let rest = strpart(m, len(key))
|
||||
if key == 'i' | let key = 'idt' | endif
|
||||
@@ -837,7 +840,7 @@ function! s:parse_shorthand_opts(expr)
|
||||
let key = 'f'
|
||||
endif
|
||||
|
||||
if key == 'idt' || index(['d', 'f', 'm'], key[0]) >= 0
|
||||
if key == 'idt' || index(['d', 'f', 'm', 'a'], key[0]) >= 0
|
||||
let opts[key] = rest
|
||||
elseif key == 'ig'
|
||||
try
|
||||
@@ -850,6 +853,8 @@ function! s:parse_shorthand_opts(expr)
|
||||
catch
|
||||
call s:exit("Invalid ignore_groups: ". a:expr)
|
||||
endtry
|
||||
elseif key == '<'
|
||||
let opts['stl'] = 1
|
||||
else
|
||||
let opts[key] = str2nr(rest)
|
||||
endif
|
||||
@@ -1025,7 +1030,7 @@ function! s:process(range, mode, n, ch, opts, regexp, rules, bvis)
|
||||
let [nth, recur] = s:parse_nth(a:n)
|
||||
let dict = s:build_dict(a:rules, a:ch, a:regexp, a:opts)
|
||||
let [mode_sequence, recur] = s:build_mode_sequence(
|
||||
\ get(dict, 'mode_sequence', recur == 2 ? s:alternating_modes(a:mode) : a:mode),
|
||||
\ get(dict, 'align', recur == 2 ? s:alternating_modes(a:mode) : a:mode),
|
||||
\ recur)
|
||||
|
||||
if recur && a:bvis
|
||||
@@ -1050,11 +1055,11 @@ endfunction
|
||||
function s:summarize(opts, recur, mode_sequence)
|
||||
let copts = s:compact_options(a:opts)
|
||||
let nbmode = s:interactive_modes(0)[0]
|
||||
if !has_key(copts, 'm') && (
|
||||
if !has_key(copts, 'a') && (
|
||||
\ (a:recur == 2 && s:alternating_modes(nbmode) != a:mode_sequence) ||
|
||||
\ (a:recur != 2 && (a:mode_sequence[0] != nbmode || len(a:mode_sequence) > 1))
|
||||
\ )
|
||||
call extend(copts, { 'm': a:mode_sequence })
|
||||
call extend(copts, { 'a': a:mode_sequence })
|
||||
endif
|
||||
return copts
|
||||
endfunction
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
easy-align.txt vim-easy-align Last change: May 31 2014
|
||||
easy-align.txt vim-easy-align Last change: July 23 2014
|
||||
|
||||
VIM-EASY-ALIGN - TABLE OF CONTENTS *easyalign* *easy-align* *easy-align-toc*
|
||||
==============================================================================
|
||||
@@ -158,7 +158,7 @@ shortcuts for the most common use cases with the concept of "alignment rule".
|
||||
|
||||
An alignment rule is a predefined set of options for common alignment tasks,
|
||||
which is identified by a single character, DELIMITER KEY, such as <Space> ,
|
||||
`=`, `:`, `.`, `|`, `&`, and `,`.
|
||||
`=`, `:`, `.`, `|`, `&`, `#`, and `,`.
|
||||
|
||||
Think of it as a shortcut. Instead of writing regular expression and setting
|
||||
several options, you can just type in a single character.
|
||||
@@ -231,7 +231,7 @@ With these mappings, you can align text with only a few keystrokes.
|
||||
- `-` Around the last occurrences of delimiters (`-1`)
|
||||
- `-2` Around the second to last occurrences of delimiters
|
||||
- ...
|
||||
4. Delimiter key (a single keystroke; <Space> , `=`, `:`, `.`, `|`, `&`, `,`)
|
||||
4. Delimiter key (a single keystroke; <Space> , `=`, `:`, `.`, `|`, `&`, `#`, `,`)
|
||||
|
||||
|
||||
Predefined alignment rules~
|
||||
@@ -246,6 +246,7 @@ Predefined alignment rules~
|
||||
`.` | Multi-line method chaining
|
||||
`,` | Multi-line method arguments
|
||||
`&` | LaTeX tables (matches `&` and `\\` )
|
||||
`#` | Ruby/Python comments
|
||||
<Bar> | Table markdown
|
||||
|
||||
*g:easy_align_delimiters*
|
||||
@@ -260,13 +261,13 @@ Examples~
|
||||
*easy-align-5-3-2*
|
||||
|
||||
With visual map | Description | Equivalent command~
|
||||
------------------- | ---------------------------------- | ----------------------
|
||||
------------------- | ---------------------------------- | ---------------------
|
||||
<Enter><Space> | Around 1st whitespaces | :'<,'>EasyAlign\
|
||||
<Enter>2<Space> | Around 2nd whitespaces | :'<,'>EasyAlign2\
|
||||
<Enter>-<Space> | Around the last whitespaces | :'<,'>EasyAlign-\
|
||||
<Enter>-2<Space> | Around the 2nd to last whitespaces | :'<,'>EasyAlign-2\
|
||||
<Enter>: | Around 1st colon (`key: value`) | :'<,'>EasyAlign:
|
||||
<Enter><Right>: | Around 1st colon (`key : value`) | :'<,'>EasyAlign:s0l1
|
||||
<Enter><Right>: | Around 1st colon (`key : value`) | :'<,'>EasyAlign:<l1
|
||||
<Enter>= | Around 1st operators with = | :'<,'>EasyAlign=
|
||||
<Enter>3= | Around 3rd operators with = | :'<,'>EasyAlign3=
|
||||
<Enter>*= | Around all operators with = | :'<,'>EasyAlign*=
|
||||
@@ -306,7 +307,7 @@ following sections (|easy-align-alignment-options|).
|
||||
CTRL-D | `delimiter_align` | left, center, right
|
||||
CTRL-U | `ignore_unmatched` | 0, 1
|
||||
CTRL-G | `ignore_groups` | [], ['String'], ['Comment'], ['String', 'Comment']
|
||||
CTRL-O | `mode_sequence` | Input string (`/[lrc]+\*{0,2}/` )
|
||||
CTRL-A | `align` | Input string (`/[lrc]+\*{0,2}/` )
|
||||
<Left> | `stick_to_left` | `{ 'stick_to_left': 1, 'left_margin': 0 }`
|
||||
<Right> | `stick_to_left` | `{ 'stick_to_left': 0, 'left_margin': 1 }`
|
||||
<Down> | `*_margin` | `{ 'left_margin': 0, 'right_margin': 0 }`
|
||||
@@ -375,20 +376,20 @@ You can even omit spaces between the arguments, so concisely (or cryptically):
|
||||
Nice. But let's make it even shorter. Option values can be written in shorthand
|
||||
notation.
|
||||
|
||||
- `:EasyAlign*/[:;]\+/s1l0`
|
||||
- `:EasyAlign*/[:;]\+/<l0`
|
||||
|
||||
The following table summarizes the shorthand notation.
|
||||
|
||||
Option | Expression~
|
||||
------------------ | ----------
|
||||
------------------ | --------------
|
||||
`filter` | `[gv]/.*/`
|
||||
`left_margin` | `l[0-9]+`
|
||||
`right_margin` | `r[0-9]+`
|
||||
`stick_to_left` | `s[01]`
|
||||
`stick_to_left` | `<` or `s[01]`
|
||||
`ignore_unmatched` | `iu[01]`
|
||||
`ignore_groups` | `ig\[.*\]`
|
||||
`align` | `a[lrc*]*`
|
||||
`delimiter_align` | `d[lrc]`
|
||||
`mode_sequence` | `m[lrc*]*`
|
||||
`indentation` | `i[ksdn]`
|
||||
|
||||
For your information, the same operation can be done in interactive mode as
|
||||
@@ -448,7 +449,7 @@ ALIGNMENT OPTIONS *easy-align-alignment-options*
|
||||
`ignore_unmatched` | boolean | 1 | Whether to ignore lines without matching delimiter
|
||||
`indentation` | string | `k` | Indentation method (keep, deep, shallow, none)
|
||||
`delimiter_align` | string | `r` | Determines how to align delimiters of different lengths
|
||||
`mode_sequence` | string | | Alignment modes for multiple occurrences of delimiters
|
||||
`align` | string | | Alignment modes for multiple occurrences of delimiters
|
||||
|
||||
There are 4 ways to set alignment options (from lowest precedence to highest):
|
||||
|
||||
@@ -470,7 +471,7 @@ There are 4 ways to set alignment options (from lowest precedence to highest):
|
||||
`ignore_unmatched` | CTRL-U | `iu[01]` | `g:easy_align_ignore_unmatched`
|
||||
`indentation` | CTRL-I | `i[ksdn]` | `g:easy_align_indentation`
|
||||
`delimiter_align` | CTRL-D | `d[lrc]` | `g:easy_align_delimiter_align`
|
||||
`mode_sequence` | CTRL-O | `m[lrc*]*` |
|
||||
`align` | CTRL-A | `m[lrc*]*` |
|
||||
|
||||
|
||||
< Filtering lines >___________________________________________________________~
|
||||
@@ -556,7 +557,10 @@ For example if you set `ignore_groups` option to be an empty list, you get
|
||||
'grape: fruits': 3
|
||||
}
|
||||
<
|
||||
Satisfied?
|
||||
If a pattern in `ignore_groups` is prepended by a `!`, it will have the
|
||||
opposite meaning. For instance, if `ignore_groups` is given as `['!Comment']`,
|
||||
delimiters that are not highlighted as Comment will be ignored during the
|
||||
alignment.
|
||||
|
||||
|
||||
< Ignoring unmatched lines >__________________________________________________~
|
||||
@@ -724,36 +728,36 @@ To recap:
|
||||
:EasyAlign! **=
|
||||
<
|
||||
In addition to these, you can fine-tune alignments over multiple occurrences of
|
||||
the delimiters with 'mode_sequence' option. (The option can also be set in
|
||||
interactive mode with the special key CTRL-O)
|
||||
the delimiters with 'align' option. (The option can also be set in interactive
|
||||
mode with the special key CTRL-A)
|
||||
>
|
||||
" Left alignment over the first two occurrences of delimiters
|
||||
:EasyAlign = { 'mode_sequence': 'll' }
|
||||
:EasyAlign = { 'align': 'll' }
|
||||
|
||||
" Right, left, center alignment over the 1st to 3rd occurrences of delimiters
|
||||
:EasyAlign = { 'm': 'rlc' }
|
||||
:EasyAlign = { 'a': 'rlc' }
|
||||
|
||||
" Using shorthand notation
|
||||
:EasyAlign = mrlc
|
||||
:EasyAlign = arlc
|
||||
|
||||
" Right, left, center alignment over the 2nd to 4th occurrences of delimiters
|
||||
:EasyAlign 2=mrlc
|
||||
:EasyAlign 2=arlc
|
||||
|
||||
" (*) Repeating alignments (default: l, r, or c)
|
||||
" Right, left, center, center, center, center, ...
|
||||
:EasyAlign *=mrlc
|
||||
:EasyAlign *=arlc
|
||||
|
||||
" (**) Alternating alignments (default: lr or rl)
|
||||
" Right, left, center, right, left, center, ...
|
||||
:EasyAlign **=mrlc
|
||||
:EasyAlign **=arlc
|
||||
|
||||
" Right, left, center, center, center, ... repeating alignment
|
||||
" over the 3rd to the last occurrences of delimiters
|
||||
:EasyAlign 3=mrlc*
|
||||
:EasyAlign 3=arlc*
|
||||
|
||||
" Right, left, center, right, left, center, ... alternating alignment
|
||||
" over the 3rd to the last occurrences of delimiters
|
||||
:EasyAlign 3=mrlc**
|
||||
:EasyAlign 3=arlc**
|
||||
<
|
||||
|
||||
< Extending alignment rules >_________________________________________________~
|
||||
@@ -774,8 +778,10 @@ Examples~
|
||||
>
|
||||
let g:easy_align_delimiters = {
|
||||
\ '>': { 'pattern': '>>\|=>\|>' },
|
||||
\ '/': { 'pattern': '//\+\|/\*\|\*/', 'ignore_groups': ['String'] },
|
||||
\ '#': { 'pattern': '#\+', 'ignore_groups': ['String'], 'delimiter_align': 'l' },
|
||||
\ '/': {
|
||||
\ 'pattern': '//\+\|/\*\|\*/',
|
||||
\ 'delimiter_align': 'l',
|
||||
\ 'ignore_groups': ['!Comment'] },
|
||||
\ ']': {
|
||||
\ 'pattern': '[[\]]',
|
||||
\ 'left_margin': 0,
|
||||
@@ -789,8 +795,8 @@ Examples~
|
||||
\ 'stick_to_left': 0
|
||||
\ },
|
||||
\ 'd': {
|
||||
\ 'pattern': ' \(\S\+\s*[;=]\)\@=',
|
||||
\ 'left_margin': 0,
|
||||
\ 'pattern': ' \(\S\+\s*[;=]\)\@=',
|
||||
\ 'left_margin': 0,
|
||||
\ 'right_margin': 0
|
||||
\ }
|
||||
\ }
|
||||
|
||||
@@ -40,14 +40,21 @@ Expect:
|
||||
apple;:;;banana :: cake
|
||||
data ;; exchange:;::format
|
||||
|
||||
Execute (shorthand notation of mode_sequence and margin):
|
||||
Execute (DEPRECATED: shorthand notation of mode_sequence and margin):
|
||||
%EasyAlign/[:;]\+/mrc*l2r2
|
||||
|
||||
Expect:
|
||||
apple ;:;; banana :: cake
|
||||
data ;; exchange :;:: format
|
||||
|
||||
Execute (deep indentation):
|
||||
Execute (shorthand notation of align and margin):
|
||||
%EasyAlign/[:;]\+/arc*l2r2
|
||||
|
||||
Expect:
|
||||
apple ;:;; banana :: cake
|
||||
data ;; exchange :;:: format
|
||||
|
||||
Execute (DEPRECATED: deep indentation):
|
||||
%EasyAlign/[:;]\+/mrc*l2r2
|
||||
%EasyAlign*/[:;]\+/idmrl*
|
||||
|
||||
@@ -55,6 +62,14 @@ Expect:
|
||||
apple ;:;; banana :: cake
|
||||
data ;; exchange :;:: format
|
||||
|
||||
Execute (deep indentation):
|
||||
%EasyAlign/[:;]\+/arc*l2r2
|
||||
%EasyAlign*/[:;]\+/idarl*
|
||||
|
||||
Expect:
|
||||
apple ;:;; banana :: cake
|
||||
data ;; exchange :;:: format
|
||||
|
||||
Execute (stick_to_left):
|
||||
%EasyAlign*/[:;]\+/stl1l0dlrm3
|
||||
|
||||
@@ -62,6 +77,13 @@ Expect:
|
||||
apple;:;; banana:: cake
|
||||
data;; exchange:;:: format
|
||||
|
||||
Execute (<):
|
||||
%EasyAlign*/[:;]\+/<l0dlrm3
|
||||
|
||||
Expect:
|
||||
apple;:;; banana:: cake
|
||||
data;; exchange:;:: format
|
||||
|
||||
Execute (different regular expression):
|
||||
%EasyAlign*/../{'lm':'<','rm':'>'}
|
||||
|
||||
|
||||
@@ -758,7 +758,7 @@ Expect ruby:
|
||||
dddddd /= 123
|
||||
gg <=> ee
|
||||
|
||||
Do (Alignment using mode_sequence, delimiter_align):
|
||||
Do (DEPRECATED: Alignment using mode_sequence, delimiter_align):
|
||||
vip\<Enter>\<C-O>\<Backspace>cr*\<Enter>\<C-D>=
|
||||
|
||||
Expect ruby:
|
||||
@@ -787,7 +787,37 @@ Expect ruby:
|
||||
dddddd /= 123
|
||||
gg <=> ee
|
||||
|
||||
Do (mode_sequence starting from 2nd, delimiter_align = center):
|
||||
Do (Alignment using align, delimiter_align):
|
||||
vip\<Enter>\<C-A>\<Backspace>cr*\<Enter>\<C-D>=
|
||||
|
||||
Expect ruby:
|
||||
a =
|
||||
a = 1
|
||||
bbbb .= 2
|
||||
ccccccc = 3
|
||||
ccccccccccccccc
|
||||
ddd = #
|
||||
eeee === eee = eee = eee = f
|
||||
fff = ggg += gg &&= gg
|
||||
g != hhhhhhhh == # 8
|
||||
i := 5
|
||||
i %= 5
|
||||
i *= 5
|
||||
j =~ 5
|
||||
j >= 5
|
||||
aa => 123
|
||||
aa <<= 123
|
||||
aa >>= 123
|
||||
bbb => 123
|
||||
c => 1233123
|
||||
d => 123
|
||||
dddddd &&= 123
|
||||
dddddd ||= 123
|
||||
dddddd /= 123
|
||||
gg <=> ee
|
||||
|
||||
|
||||
Do (DEPRECATED: mode_sequence starting from 2nd, delimiter_align = center):
|
||||
vip\<Enter>\<C-O>\<Backspace>rc**\<Enter>\<C-D>\<C-D>2=
|
||||
|
||||
Expect ruby:
|
||||
@@ -816,6 +846,35 @@ Expect ruby:
|
||||
dddddd /= 123
|
||||
gg <=> ee
|
||||
|
||||
Do (align starting from 2nd, delimiter_align = center):
|
||||
vip\<Enter>\<C-A>\<Backspace>rc**\<Enter>\<C-D>\<C-D>2=
|
||||
|
||||
Expect ruby:
|
||||
a =
|
||||
a = 1
|
||||
bbbb .= 2
|
||||
ccccccc = 3
|
||||
ccccccccccccccc
|
||||
ddd = #
|
||||
eeee === eee = eee = eee = f
|
||||
fff = ggg += gg &&= gg
|
||||
g != hhhhhhhh == # 8
|
||||
i := 5
|
||||
i %= 5
|
||||
i *= 5
|
||||
j =~ 5
|
||||
j >= 5
|
||||
aa => 123
|
||||
aa <<= 123
|
||||
aa >>= 123
|
||||
bbb => 123
|
||||
c => 1233123
|
||||
d => 123
|
||||
dddddd &&= 123
|
||||
dddddd ||= 123
|
||||
dddddd /= 123
|
||||
gg <=> ee
|
||||
|
||||
Do (around all =s, do not ignore unmatched):
|
||||
vip\<Enter>\<C-U>
|
||||
\<C-L>0\<Enter>
|
||||
|
||||
Reference in New Issue
Block a user