Skip to content
Browse files

fixed indent, fixed key assign.

  • Loading branch information...
1 parent d0c9e61 commit d317c5f47c3837bb4ae1e2befd9b3d6de5977384 @mattn committed Nov 8, 2011
Showing with 19 additions and 9 deletions.
  1. +1 −0 Makefile
  2. +11 −6 autoload/sonictemplate.vim
  3. +7 −3 plugin/sonictemplate.vim
View
1 Makefile
@@ -5,6 +5,7 @@ remove-zip:
-rm sonictemplate-vim.zip
sonictemplate-vim.zip: remove-zip
+ find template -type f -exec -print | xargs dos2unix --d2u
zip -r sonictemplate-vim.zip autoload plugin doc template
release: sonictemplate-vim.zip
View
17 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
View
10 plugin/sonictemplate.vim
@@ -1,7 +1,7 @@
"=============================================================================
" File: sonictemplate.vim
" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
-" Last Change: 02-Nov-2011.
+" Last Change: 08-Nov-2011.
" Version: 0.06
" WebPage: http://github.com/mattn/sonictemplate-vim
" Description: Easy and high speed coding method
@@ -21,8 +21,12 @@ let s:save_cpo = &cpo
set cpo&vim
command! -nargs=1 -complete=customlist,sonictemplate#complete Template call sonictemplate#apply(<f-args>)
-nnoremap <c-y>t :call sonictemplate#select()<cr>
-inoremap <c-y>t <space><bs><c-\><c-o>:call sonictemplate#select()<cr>
+
+nnoremap <plug>(sonictemplate) :call sonictemplate#select('n')<cr>
+inoremap <plug>(sonictemplate) <space><bs><c-o>:call sonictemplate#select('i')<cr>
+
+nmap <unique> <c-y>t <plug>(sonictemplate)
+imap <unique> <c-y>t <plug>(sonictemplate)
let &cpo = s:save_cpo
unlet s:save_cpo

0 comments on commit d317c5f

Please sign in to comment.
Something went wrong with that request. Please try again.