From c5fcca78ab9fdc561d14e617d448dae2cc3e055b Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Sun, 20 Dec 2009 15:35:57 +0800 Subject: [PATCH] Don't add leading space in empty first column --- autoload/tabular.vim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/autoload/tabular.vim b/autoload/tabular.vim index dd1a623..9ed6033 100644 --- a/autoload/tabular.vim +++ b/autoload/tabular.vim @@ -206,6 +206,8 @@ function! tabular#TabularizeStrings(strings, delim, ...) endfor endfor + let lead_blank = empty(filter(copy(lines), 'v:val[0] =~ "\\S"')) + " Concatenate the fields, according to the format pattern. for idx in range(len(lines)) let line = lines[idx] @@ -221,7 +223,7 @@ function! tabular#TabularizeStrings(strings, delim, ...) let field = s:Center(line[i], maxes[i]) endif - let line[i] = field . repeat(" ", pad) + let line[i] = field . (lead_blank && i == 0 ? '' : repeat(" ", pad)) endfor let lines[idx] = s:StripTrailingSpaces(join(line, ''))