aboutsummaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorYasuhiro Matsumoto <mattn.jp@gmail.com>2016-07-04 09:49:41 +0900
committerYasuhiro Matsumoto <mattn.jp@gmail.com>2016-07-04 09:49:41 +0900
commitffb805ca09df9530c806a25b86cadb48892fa40f (patch)
tree236e0a6a41de43e7662f424b33e459767b7ae5da /autoload
parent58b5595f88909e9d45eb338e31d2952a8e1d9c8f (diff)
downloadvim-sonictemplate-ffb805ca09df9530c806a25b86cadb48892fa40f.tar.gz
vim-sonictemplate-ffb805ca09df9530c806a25b86cadb48892fa40f.tar.bz2
vim-sonictemplate-ffb805ca09df9530c806a25b86cadb48892fa40f.zip
add postfix for go
Diffstat (limited to 'autoload')
-rw-r--r--autoload/sonictemplate.vim23
1 files changed, 16 insertions, 7 deletions
diff --git a/autoload/sonictemplate.vim b/autoload/sonictemplate.vim
index 91f45df..c543b20 100644
--- a/autoload/sonictemplate.vim
+++ b/autoload/sonictemplate.vim
@@ -333,19 +333,28 @@ function! sonictemplate#postfix()
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 lhs = col('.') > 1 ? line[:col('.')-2] : ''
let rhs = line[len(lhs):]
let lhs = lhs[len(indent):]
let c = lhs . c . rhs
endif
- call setline('.', line)
- silent! exe "normal! a\<c-r>=c\<cr>"
+ if c =~ "\n"
+ let c = indent . substitute(substitute(c, "\n", "\n".indent, 'g'), "\n".indent."\n", "\n\n", 'g')
+ 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
+ call setline('.', line)
+ if line('.') < line('$')
+ silent! normal! dd
+ endif
+ silent! put! =c
+ else
+ call setline('.', line)
+ silent! exe "normal! a\<c-r>=c\<cr>"
+ endif
if stridx(c, '{{_cursor_}}') != -1
silent! call search('{{_cursor_}}\zs', 'w')
silent! foldopen