aboutsummaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authormattn <mattn.jp@gmail.com>2012-06-06 22:26:31 +0900
committermattn <mattn.jp@gmail.com>2012-06-06 22:26:31 +0900
commit8f75ad0207ddb7d89de2386d9b050898cfa32603 (patch)
tree7eee17da721728e58a18baeab02d6b35c5008e70 /autoload
parent356eb551a3ec4d1e0419707727c1c48f9ce8cf55 (diff)
downloadvim-sonictemplate-8f75ad0207ddb7d89de2386d9b050898cfa32603.tar.gz
vim-sonictemplate-8f75ad0207ddb7d89de2386d9b050898cfa32603.tar.bz2
vim-sonictemplate-8f75ad0207ddb7d89de2386d9b050898cfa32603.zip
add {{_inline_}}.
Diffstat (limited to 'autoload')
-rw-r--r--autoload/sonictemplate.vim27
1 files changed, 17 insertions, 10 deletions
diff --git a/autoload/sonictemplate.vim b/autoload/sonictemplate.vim
index 6f0978a..b67f577 100644
--- a/autoload/sonictemplate.vim
+++ b/autoload/sonictemplate.vim
@@ -1,7 +1,7 @@
"=============================================================================
" sonictemplate.vim
" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
-" Last Change: 29-May-2012.
+" Last Change: 06-Jun-2012.
let s:save_cpo = &cpo
set cpo&vim
@@ -107,16 +107,23 @@ function! sonictemplate#apply(name, mode) abort
if c[len(c)-1] == "\n"
let c = c[:-2]
endif
- let line = getline('.')
- let indent = matchstr(line, '^\(\s*\)')
- if line =~ '^\s*$' && line('.') != line('$')
- silent! normal dd
- endif
- let c = indent . substitute(substitute(c, "\n", "\n".indent, 'g'), "\n".indent."\n", "\n\n", 'g')
- if len(indent) && (&expandtab || &tabstop != &shiftwidth || indent =~ '^ \+$')
- let c = substitute(c, "\t", repeat(' ', min([len(indent), &shiftwidth])), 'g')
+ if stridx(c, '{{_inline_}}') != -1
+ let c = substitute(c, '{{_inline_}}', '', 'g')
+ let c = join(split(c, "\n"), "")
+ silent! exe "normal! a\<c-r>=c\<cr>"
+ return
+ else
+ let line = getline('.')
+ let indent = matchstr(line, '^\(\s*\)')
+ if line =~ '^\s*$' && line('.') != line('$')
+ silent! normal dd
+ endif
+ let c = indent . substitute(substitute(c, "\n", "\n".indent, 'g'), "\n".indent."\n", "\n\n", 'g')
+ if len(indent) && (&expandtab || &tabstop != &shiftwidth || indent =~ '^ \+$')
+ let c = substitute(c, "\t", repeat(' ', min([len(indent), &shiftwidth])), 'g')
+ endif
+ silent! put! =c
endif
- silent! put! = c
endif
if stridx(c, '{{_cursor_}}') != -1
if a:mode == 'n'