aboutsummaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authormattn <mattn.jp@gmail.com>2011-11-08 18:49:55 +0900
committermattn <mattn.jp@gmail.com>2011-11-08 18:49:55 +0900
commitd317c5f47c3837bb4ae1e2befd9b3d6de5977384 (patch)
tree659c25b69f34ed4181da6ffd8e1bea2336aefa42 /autoload
parentd0c9e61ccf69fb6c3f7f2877d937c04887dae9d7 (diff)
downloadvim-sonictemplate-d317c5f47c3837bb4ae1e2befd9b3d6de5977384.tar.gz
vim-sonictemplate-d317c5f47c3837bb4ae1e2befd9b3d6de5977384.tar.bz2
vim-sonictemplate-d317c5f47c3837bb4ae1e2befd9b3d6de5977384.zip
fixed indent, fixed key assign.
Diffstat (limited to 'autoload')
-rw-r--r--autoload/sonictemplate.vim17
1 files changed, 11 insertions, 6 deletions
diff --git a/autoload/sonictemplate.vim b/autoload/sonictemplate.vim
index 26c3674..730d318 100644
--- a/autoload/sonictemplate.vim
+++ b/autoload/sonictemplate.vim
@@ -1,7 +1,7 @@
"=============================================================================
" sonictemplate.vim
" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
-" Last Change: 02-Nov-2011.
+" Last Change: 08-Nov-2011.
let s:save_cpo = &cpo
set cpo&vim
@@ -12,12 +12,12 @@ else
let s:tmpldir = expand('<sfile>:p:h:h') . '/template/'
endif
-function! sonictemplate#select() abort
+function! sonictemplate#select(mode) abort
let name = input(':Template ', '', 'customlist,sonictemplate#complete')
if name == ''
return
endif
- silent! call sonictemplate#apply(name)
+ call sonictemplate#apply(name, a:mode)
endfunction
function! sonictemplate#complete(lead, cmdline, curpos) abort
@@ -28,7 +28,7 @@ function! sonictemplate#complete(lead, cmdline, curpos) abort
endif
endfunction
-function! sonictemplate#apply(name) abort
+function! sonictemplate#apply(name, mode) abort
let buffer_is_not_empty = search('[^ \t]', 'wn')
if search('[^ \t]', 'wn')
let fs = split(globpath(join([s:tmpldir, &ft], '/'), 'snip-' . a:name . '.*'), "\n")
@@ -89,8 +89,13 @@ function! sonictemplate#apply(name) abort
silent! put! = c
endif
if stridx(c, '{{_cursor_}}') != -1
- silent! call search('{{_cursor_}}\zs', 'w')
- silent! exe "normal a".repeat("\<bs>", 12)
+ if a:mode == 'n'
+ silent! call search('\zs{{_cursor_}}', 'w')
+ silent! exe "normal ".repeat("x", 12)
+ else
+ silent! call search('{{_cursor_}}\zs', 'w')
+ call feedkeys(repeat("\<bs>", 12))
+ endif
endif
endfunction