mirror of
https://github.com/junegunn/vim-easy-align.git
synced 2025-11-10 10:53:49 -05:00
Implement stick_to_left in center-alignment mode
This commit is contained in:
@@ -414,6 +414,15 @@ function! s:do_align(modes, all_tokens, all_delims, fl, ll, fc, lc, pattern, nth
|
||||
let strip = float2nr(ceil((max.token_len - max.strip_len) / 2.0))
|
||||
let token = repeat(' ', float2nr(pf1)) .token. repeat(' ', float2nr(p2))
|
||||
let token = substitute(token, repeat(' ', strip) . '$', '', '')
|
||||
|
||||
if a:stick_to_left
|
||||
if empty(s:rtrim(token))
|
||||
let center = len(token) / 2
|
||||
let [token, rpad] = [strpart(token, 0, center), strpart(token, center)]
|
||||
else
|
||||
let [token, rpad] = [s:rtrim(token), matchstr(token, '\s*$')]
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
let tokens[nth] = token
|
||||
|
||||
|
||||
@@ -1041,3 +1041,10 @@ aaaaaaaaaaa = 123
|
||||
|
||||
```
|
||||
|
||||
a, , bbb
|
||||
aa, , bb
|
||||
aaa, , b
|
||||
aaaa, ,
|
||||
aaa, b,
|
||||
aa, bb,
|
||||
a, bbb,
|
||||
|
||||
@@ -258,3 +258,10 @@ cccccccccccccccccc = 12345678 =
|
||||
|
||||
```
|
||||
|
||||
a,,bbb
|
||||
aa,,bb
|
||||
aaa,,b
|
||||
aaaa,,
|
||||
aaa,b,
|
||||
aa,bb,
|
||||
a,bbb,
|
||||
|
||||
@@ -1 +1 @@
|
||||
4Gvipjyvip
|
||||
4Gvipjyvip
|
||||
|
||||
Reference in New Issue
Block a user