From 249a9b048db8e2666549c6eda59a23ddf2d423b9 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Fri, 1 Jul 2016 19:12:11 +0900 Subject: replace tabs --- autoload/sonictemplate.vim | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'autoload') diff --git a/autoload/sonictemplate.vim b/autoload/sonictemplate.vim index 72e5104..d0cfdd9 100644 --- a/autoload/sonictemplate.vim +++ b/autoload/sonictemplate.vim @@ -331,8 +331,13 @@ function! sonictemplate#pattern() for i in range(1, 9) let c = substitute(c, '{{$' . i . '}}', ml[i], 'g') endfor + let indent = matchstr(line, '^\(\s*\)') + if len(indent) && (&expandtab || (&shiftwidth && &tabstop != &shiftwidth) || indent =~ '^ \+$') + let c = substitute(c, "\t", repeat(' ', min([len(indent), &shiftwidth])), 'g') + elseif &expandtab || (&shiftwidth && &tabstop != &shiftwidth) + let c = substitute(c, "\t", repeat(' ', &shiftwidth), 'g') + endif if line !~ '^\s*$' - let indent = matchstr(line, '^\(\s*\)') let lhs = col('.') > 1 ? line[:col('.')-2] : '' let rhs = line[len(lhs):] let lhs = lhs[len(indent):] -- cgit v1.2.3-54-g00ecf