aboutsummaryrefslogtreecommitdiff
path: root/plugin/sonictemplate.vim
blob: 6c8a6faaacd03f9f02b6cdd3e7ef9a24b46794d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"=============================================================================
" File: sonictemplate.vim
" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
" Last Change: 01-May-2013.
" Version: 0.10
" WebPage: http://github.com/mattn/sonictemplate-vim
" Description: Easy and high speed coding method
" Usage:
"
"   :Template {name}
"       Load template named as {name} in the current buffer.
"
"   Or type <c-y> + t

if &cp || (exists('g:loaded_sonictemplate_vim') && g:loaded_sonictemplate_vim)
  finish
endif
let g:loaded_sonictemplate_vim = 1

let s:save_cpo = &cpo
set cpo&vim

exe "command!" "-nargs=1" "-complete=customlist,sonictemplate#complete" get(g:, 'sonictemplate_commandname', 'Template') "call sonictemplate#apply(<f-args>, 'n')"

nnoremap <plug>(sonictemplate) :call sonictemplate#select('n')<cr>
inoremap <plug>(sonictemplate) <c-r>=sonictemplate#select('i')<cr>

if get(g:, 'sonictemplate_key', '') == ''
  nmap <unique> <c-y>t <plug>(sonictemplate)
  imap <unique> <c-y>t <plug>(sonictemplate)
  nmap <unique> <c-y><c-t> <plug>(sonictemplate)
  imap <unique> <c-y><c-t> <plug>(sonictemplate)
else
  exe "nnoremap" g:sonictemplate_key "<plug>(sonictemplate)"
  exe "inoremap" g:sonictemplate_key "<plug>(sonictemplate)"
endif

nnoremap <plug>(sonictemplate-intelligent) :call sonictemplate#select_intelligent('n')<cr>
inoremap <plug>(sonictemplate-intelligent) <c-r>=sonictemplate#select_intelligent('i')<cr>
if get(g:, 'sonictemplate_intelligent_key', '') == ''
  nmap <unique> <c-y>T <plug>(sonictemplate-intelligent)
  imap <unique> <c-y>T <plug>(sonictemplate-intelligent)
else
  exe "nnoremap" g:sonictemplate_intelligent_key "<plug>(sonictemplate-intelligent)"
  exe "inoremap" g:sonictemplate_intelligent_key "<plug>(sonictemplate-intelligent)"
endif

inoremap <plug>(sonictemplate-postfix) <c-r>=sonictemplate#postfix()<cr>
if get(g:, 'sonictemplate_postfix_key', '') == ''
  imap <unique> <c-y><c-b> <plug>(sonictemplate-postfix)
else
  exe "inoremap" g:sonictemplate_postfix_key "<plug>(sonictemplate-postfix)"
endif

let &cpo = s:save_cpo
unlet s:save_cpo

" vim:set et: