mirror of
https://github.com/junegunn/vim-easy-align.git
synced 2025-11-09 10:23:49 -05:00
Add g:easy_align_indentation. Add n indentation option.
This commit is contained in:
27
README.md
27
README.md
@@ -85,6 +85,9 @@ Alignment rules for the following delimiters have been defined to meet the most
|
||||
| `,` | Multi-line method arguments |
|
||||
| | | Table markdown |
|
||||
|
||||
You can override these default rules or define your own rules with
|
||||
`g:easy_align_delimiters`, which will be described in the later section.
|
||||
|
||||
#### Example command sequences
|
||||
|
||||
| With visual map | Description | Equivalent command |
|
||||
@@ -196,7 +199,7 @@ lowest precedence.
|
||||
| `stick_to_left` | boolean | 0 | Whether to position delimiter on the left-side |
|
||||
| `ignore_unmatched` | boolean | 1 | Whether to ignore lines without matching delimiter |
|
||||
| `ignores` | list | ['String', 'Comment'] | Delimiters in these syntax highlight groups are ignored |
|
||||
| `indentation` | string | `k` | Indentation method (*k*eep, *d*eep, *s*hallow) |
|
||||
| `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 |
|
||||
|
||||
Some of the options can be specified using corresponding global variables.
|
||||
@@ -206,6 +209,7 @@ Some of the options can be specified using corresponding global variables.
|
||||
| `ignore_unmatched` | `g:easy_align_ignore_unmatched` |
|
||||
| `ignores` | `g:easy_align_ignores` |
|
||||
| `delimiter_align` | `g:easy_align_delimiter_align` |
|
||||
| `indentation` | `g:easy_align_indentation` |
|
||||
|
||||
### Ignoring delimiters in comments or strings
|
||||
|
||||
@@ -359,35 +363,44 @@ By default :EasyAlign command keeps the original indentation of the lines. But
|
||||
then again we have `indentation` option. See the following example.
|
||||
|
||||
```ruby
|
||||
# Lines with different indentation
|
||||
apple = 1
|
||||
banana = 2
|
||||
cake = 3
|
||||
daisy = 4
|
||||
eggplant = 5
|
||||
|
||||
# Default: _k_eep the original indentation
|
||||
# :EasyAlign=
|
||||
# Default: _k_eep the original indentation
|
||||
# :EasyAlign=
|
||||
apple = 1
|
||||
banana = 2
|
||||
cake = 3
|
||||
daisy = 4
|
||||
eggplant = 5
|
||||
|
||||
# Use the _s_hallowest indentation among the lines
|
||||
# :EasyAlign={'idt':s}
|
||||
# Use the _s_hallowest indentation among the lines
|
||||
# :EasyAlign={'idt':s}
|
||||
apple = 1
|
||||
banana = 2
|
||||
cake = 3
|
||||
daisy = 4
|
||||
eggplant = 5
|
||||
|
||||
# Use the _d_eepest indentation among the lines
|
||||
# :EasyAlign={'idt':d}
|
||||
# Use the _d_eepest indentation among the lines
|
||||
# :EasyAlign={'idt':d}
|
||||
apple = 1
|
||||
banana = 2
|
||||
cake = 3
|
||||
daisy = 4
|
||||
eggplant = 5
|
||||
|
||||
# Indentation: _n_one
|
||||
# :EasyAlign={'idt':n}
|
||||
apple = 1
|
||||
banana = 2
|
||||
cake = 3
|
||||
daisy = 4
|
||||
eggplant = 5
|
||||
```
|
||||
|
||||
Notice that `idt` is fuzzy-matched to `indentation`.
|
||||
|
||||
@@ -271,6 +271,8 @@ function! s:do_align(just, all_tokens, all_delims, fl, ll, fc, lc, pattern, nth,
|
||||
let indent = repeat(' ', max_indent)
|
||||
elseif a:indentation ==? 's'
|
||||
let indent = repeat(' ', min_indent)
|
||||
elseif a:indentation ==? 'n'
|
||||
let indent = ''
|
||||
elseif a:indentation !=? 'k'
|
||||
call s:exit('Invalid indentation: ' . a:indentation)
|
||||
end
|
||||
@@ -420,8 +422,8 @@ function! s:parse_args(args)
|
||||
|
||||
let cand = strpart(args, midx)
|
||||
try
|
||||
let [l, r, c, k, s, d] = ['l', 'r', 'c', 'k', 's', 'd']
|
||||
let [L, R, C, K, S, D] = ['l', 'r', 'c', 'k', 's', 'd']
|
||||
let [l, r, c, k, s, d, n] = ['l', 'r', 'c', 'k', 's', 'd', 'n']
|
||||
let [L, R, C, K, S, D, N] = ['l', 'r', 'c', 'k', 's', 'd', 'n']
|
||||
let o = eval(cand)
|
||||
if type(o) == 4
|
||||
let option = o
|
||||
@@ -546,7 +548,7 @@ function! easy_align#align(just, expr) range
|
||||
\ ml,
|
||||
\ mr,
|
||||
\ get(dict, 'delimiter_align', get(g:, 'easy_align_delimiter_align', 'r')),
|
||||
\ get(dict, 'indentation', 'k'),
|
||||
\ get(dict, 'indentation', get(g:, 'easy_align_indentation', 'k')),
|
||||
\ get(dict, 'stick_to_left', 0),
|
||||
\ get(dict, 'ignore_unmatched', get(g:, 'easy_align_ignore_unmatched', 1)),
|
||||
\ get(dict, 'ignores', s:ignored_syntax()),
|
||||
|
||||
@@ -269,42 +269,51 @@ And on ':EasyAlign={'da':c}', center-aligned.
|
||||
cake ||= banana
|
||||
|
||||
|
||||
Adjusting indentation
|
||||
Adjusting indentation *g:easy_align_indentation*
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
By default :EasyAlign command keeps the original indentation of the lines.
|
||||
But then again we have 'indentation' option. See the following example.
|
||||
|
||||
# Lines with different indentation
|
||||
apple = 1
|
||||
banana = 2
|
||||
cake = 3
|
||||
daisy = 4
|
||||
eggplant = 5
|
||||
|
||||
# Default: _k_eep the original indentation
|
||||
# :EasyAlign=
|
||||
# Default: _k_eep the original indentation
|
||||
# :EasyAlign=
|
||||
apple = 1
|
||||
banana = 2
|
||||
cake = 3
|
||||
daisy = 4
|
||||
eggplant = 5
|
||||
|
||||
# Use the _s_hallowest indentation among the lines
|
||||
# :EasyAlign={'idt':s}
|
||||
# Use the _s_hallowest indentation among the lines
|
||||
# :EasyAlign={'idt':s}
|
||||
apple = 1
|
||||
banana = 2
|
||||
cake = 3
|
||||
daisy = 4
|
||||
eggplant = 5
|
||||
|
||||
# Use the _d_eepest indentation among the lines
|
||||
# :EasyAlign={'idt':d}
|
||||
# Use the _d_eepest indentation among the lines
|
||||
# :EasyAlign={'idt':d}
|
||||
apple = 1
|
||||
banana = 2
|
||||
cake = 3
|
||||
daisy = 4
|
||||
eggplant = 5
|
||||
|
||||
# Indentation: _n_one
|
||||
# :EasyAlign={'idt':n}
|
||||
apple = 1
|
||||
banana = 2
|
||||
cake = 3
|
||||
daisy = 4
|
||||
eggplant = 5
|
||||
|
||||
Notice that 'idt' is fuzzy-matched to 'indentation'.
|
||||
|
||||
|
||||
|
||||
@@ -510,6 +510,24 @@ George Harrison 1943
|
||||
daisy = 4 = 2
|
||||
eggplant = 5 = 2
|
||||
|
||||
apple = 1 = 2
|
||||
banana = 2 = 2
|
||||
cake = 3 = 2
|
||||
daisy = 4 = 2
|
||||
eggplant = 5 = 2
|
||||
|
||||
apple = 1 = 2
|
||||
banana = 2 = 2
|
||||
cake = 3 = 2
|
||||
daisy = 4 = 2
|
||||
eggplant = 5 = 2
|
||||
|
||||
apple = 1 = 2
|
||||
banana = 2 = 2
|
||||
cake = 3 = 2
|
||||
daisy = 4 = 2
|
||||
eggplant = 5 = 2
|
||||
|
||||
apple = 1 = 2
|
||||
banana = 2 = 2
|
||||
cake = 3 = 2
|
||||
|
||||
@@ -1 +1 @@
|
||||
4Gvipjyvip
|
||||
4Gvipjyvip
|
||||
|
||||
Reference in New Issue
Block a user