-
Notifications
You must be signed in to change notification settings - Fork 0
/
sc.vim
30 lines (26 loc) · 877 Bytes
/
sc.vim
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
command! -nargs=0 SC call <SID>ExchangeTemplateYaon()
function! s:ExchangeTemplateYaon()
let target = s:GetTargetName()
if strlen(target) <= 0 || target ==# expand('%')
echomsg 'Cannot get correspond file: ' . expand('%')
return 0
endif
echo target
if filereadable(target)
execute ':e' .target
else
echo 'Cannot read correspond file.'
endif
endfunction " s:UtestAppend()
function! s:GetTargetName()
let curr = expand('%:p')
if expand('%:e') ==# 'yaon'
let htmlfile = substitute(curr, '^\(..*\)/config\(\(/[^/][^/]*\)*\)/models-\(..*\)\.yaon$', '\1/template\2/\4.html', 'i')
return htmlfile
elseif expand('%:e') ==# 'html'
let yaonfile = substitute(curr, '^\(..*\)/template\(\(/[^/][^/]*\)*\)/\(..*\)\.html$', '\1/config\2/models-\4.yaon', 'i')
return yaonfile
else
return ''
endif
endfunction " s:GetTargetName()