mirror of
https://github.com/junegunn/vim-easy-align.git
synced 2025-11-08 18:03:49 -05:00
Shorthand notation for ignore_groups/ignore_unmatched
e.g. ig['String']iu0
This commit is contained in:
11
README.md
11
README.md
@@ -242,18 +242,15 @@ Supported shorthand notations are listed below.
|
|||||||
|
|
||||||
| Expression | Option |
|
| Expression | Option |
|
||||||
| ---------- | ---------------- |
|
| ---------- | ---------------- |
|
||||||
| `l[0-9]` | left_margin |
|
| `l[0-9]+` | left_margin |
|
||||||
| `r[0-9]` | right_margin |
|
| `r[0-9]+` | right_margin |
|
||||||
| `s[01]` | stick_to_left |
|
| `s[01]` | stick_to_left |
|
||||||
| `u[01]` | ignore_unmatched |
|
| `iu[01]` | ignore_unmatched |
|
||||||
|
| `ig\[.*\]` | ignore_groups |
|
||||||
| `d[lrc]` | delimiter_align |
|
| `d[lrc]` | delimiter_align |
|
||||||
| `m[lrc*]*` | mode_sequence |
|
| `m[lrc*]*` | mode_sequence |
|
||||||
| `i[ksdn]` | indentation |
|
| `i[ksdn]` | indentation |
|
||||||
|
|
||||||
Notice that some option values cannot be expressed in shorthand notation.
|
|
||||||
|
|
||||||
- `:EasyAlign*/[:;]\+/s1l0 {'ig': []}`
|
|
||||||
|
|
||||||
### Partial alignment in blockwise-visual mode
|
### Partial alignment in blockwise-visual mode
|
||||||
|
|
||||||
In blockwise-visual mode (`CTRL-V`), EasyAlign command aligns only the selected
|
In blockwise-visual mode (`CTRL-V`), EasyAlign command aligns only the selected
|
||||||
|
|||||||
@@ -691,11 +691,11 @@ endfunction
|
|||||||
|
|
||||||
function! s:parse_shortcut_opts(expr)
|
function! s:parse_shortcut_opts(expr)
|
||||||
let opts = {}
|
let opts = {}
|
||||||
let expr = tolower(substitute(a:expr, '\s', '', 'g'))
|
let expr = substitute(a:expr, '\s', '', 'g')
|
||||||
let regex =
|
let regex =
|
||||||
\ '^\('
|
\ '^\('
|
||||||
\ .'\(l[0-9]\+\)\|\(r[0-9]\+\)\|\(u[01]\)\|\(s[01]\)\|'
|
\ .'\(l[0-9]\+\)\|\(r[0-9]\+\)\|\(iu[01]\)\|\(s[01]\)\|'
|
||||||
\ .'\(d[clr]\)\|\(m[lrc*]\+\)\|\(i[kdsn]\)'
|
\ .'\(d[clr]\)\|\(m[lrc*]\+\)\|\(i[kdsn]\)\|\(ig\[.*\]\)'
|
||||||
\ .'\)\+$'
|
\ .'\)\+$'
|
||||||
|
|
||||||
if empty(expr)
|
if empty(expr)
|
||||||
@@ -706,12 +706,24 @@ function! s:parse_shortcut_opts(expr)
|
|||||||
let match = matchlist(expr, regex)
|
let match = matchlist(expr, regex)
|
||||||
if empty(match) | break | endif
|
if empty(match) | break | endif
|
||||||
for m in filter(match[ 2 : -1 ], '!empty(v:val)')
|
for m in filter(match[ 2 : -1 ], '!empty(v:val)')
|
||||||
let k = m[0]
|
let k = tolower(m[0])
|
||||||
|
let kk = tolower(m[0 : 1])
|
||||||
let rest = m[1 : -1]
|
let rest = m[1 : -1]
|
||||||
if index(['l', 'r', 's'], k) >= 0
|
if index(['l', 'r', 's'], k) >= 0
|
||||||
let opts[k] = str2nr(rest)
|
let opts[k] = str2nr(rest)
|
||||||
elseif k == 'u'
|
elseif kk == 'iu'
|
||||||
let opts['iu'] = str2nr(rest)
|
let opts['iu'] = str2nr(m[2 : -1])
|
||||||
|
elseif kk == 'ig'
|
||||||
|
try
|
||||||
|
let arr = eval(m[2 : -1])
|
||||||
|
if type(arr) == 3
|
||||||
|
let opts['ig'] = arr
|
||||||
|
else
|
||||||
|
throw 'Not an array'
|
||||||
|
endif
|
||||||
|
catch
|
||||||
|
call s:exit("Invalid ignore_groups: ". a:expr)
|
||||||
|
endtry
|
||||||
elseif k == 'i'
|
elseif k == 'i'
|
||||||
let opts['idt'] = rest
|
let opts['idt'] = rest
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -167,18 +167,15 @@ Supported shorthand notations are listed below.
|
|||||||
|
|
||||||
| Expression | Option |
|
| Expression | Option |
|
||||||
| ---------- | -------------- |
|
| ---------- | -------------- |
|
||||||
| l[0-9] | left_margin |
|
| l[0-9]+ | left_margin |
|
||||||
| r[0-9] | right_margin |
|
| r[0-9]+ | right_margin |
|
||||||
| s[01] | stick_to_left |
|
| s[01] | stick_to_left |
|
||||||
| u[01] | ignore_unmatched |
|
| iu[01] | ignore_unmatched |
|
||||||
|
| ig\[.*\] | ignore_groups |
|
||||||
| d[lrc] | delimiter_align |
|
| d[lrc] | delimiter_align |
|
||||||
| m[lrc*]+ | mode_sequence |
|
| m[lrc*]+ | mode_sequence |
|
||||||
| i[ksdn] | indentation |
|
| i[ksdn] | indentation |
|
||||||
|
|
||||||
Notice that some option values cannot be expressed in shorthand notation.
|
|
||||||
|
|
||||||
:EasyAlign*/[:;]\+/s1l0 {'ig': []}
|
|
||||||
|
|
||||||
|
|
||||||
Partial alignment in blockwise-visual mode
|
Partial alignment in blockwise-visual mode
|
||||||
-------------------------------------------------------------------------
|
-------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user