From a6237c1215689ed91c3b483c87d3aab710b2c3c6 Mon Sep 17 00:00:00 2001 From: mattn Date: Mon, 28 May 2012 23:33:49 +0900 Subject: fix indent on base template. --- autoload/sonictemplate.vim | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'autoload') diff --git a/autoload/sonictemplate.vim b/autoload/sonictemplate.vim index fef7d6f..96639ff 100644 --- a/autoload/sonictemplate.vim +++ b/autoload/sonictemplate.vim @@ -1,7 +1,7 @@ "============================================================================= " sonictemplate.vim " Author: Yasuhiro Matsumoto -" Last Change: 15-Apr-2012. +" Last Change: 28-May-2012. let s:save_cpo = &cpo set cpo&vim @@ -97,6 +97,9 @@ function! sonictemplate#apply(name, mode) abort return endif if !buffer_is_not_empty + if &expandtab || &tabstop != &shiftwidth + let c = substitute(c, "\t", repeat(' ', &shiftwidth), 'g') + endif silent! %d _ silent! put = c silent! normal! ggdd @@ -110,8 +113,8 @@ function! sonictemplate#apply(name, mode) abort silent! normal dd endif let c = indent . substitute(c, "\n", "\n".indent, 'g') - if len(indent) && (&expandtab || indent =~ '^ \+$') - let c = substitute(c, "\t", repeat(' ', min([len(indent), &tabstop])), 'g') + if len(indent) && (&expandtab || &tabstop != &shiftwidth || indent =~ '^ \+$') + let c = substitute(c, "\t", repeat(' ', min([len(indent), &shiftwidth])), 'g') endif silent! put! = c endif -- cgit v1.2.3-54-g00ecf