diff options
author | mattn <mattn.jp@gmail.com> | 2012-05-28 23:33:49 +0900 |
---|---|---|
committer | mattn <mattn.jp@gmail.com> | 2012-05-28 23:33:49 +0900 |
commit | a6237c1215689ed91c3b483c87d3aab710b2c3c6 (patch) | |
tree | c035aa94b9917d72b8e22e6e2cfeec49f156eded /autoload | |
parent | e9259c19a2e71f918d0b3021dd8d310ac7dae3b4 (diff) | |
download | vim-sonictemplate-a6237c1215689ed91c3b483c87d3aab710b2c3c6.tar.gz vim-sonictemplate-a6237c1215689ed91c3b483c87d3aab710b2c3c6.tar.bz2 vim-sonictemplate-a6237c1215689ed91c3b483c87d3aab710b2c3c6.zip |
fix indent on base template.
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/sonictemplate.vim | 9 |
1 files changed, 6 insertions, 3 deletions
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 <mattn.jp@gmail.com> -" 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 |