Implement stick_to_left in center-alignment mode

This commit is contained in:
Junegunn Choi
2013-08-23 17:47:03 +09:00
parent 01337b9c4e
commit 25fec2e955
4 changed files with 24 additions and 1 deletions

View File

@@ -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

View File

@@ -1041,3 +1041,10 @@ aaaaaaaaaaa = 123
```
a, , bbb
aa, , bb
aaa, , b
aaaa, ,
aaa, b,
aa, bb,
a, bbb,

View File

@@ -258,3 +258,10 @@ cccccccccccccccccc = 12345678 =
```
a,,bbb
aa,,bb
aaa,,b
aaaa,,
aaa,b,
aa,bb,
a,bbb,

View File

@@ -1 +1 @@
4Gvipjyvip
4Gvipjyvip