" Use :Skel to apply skeleton (template) to empty new file (skeleton is " dot-file from vimfiles/skel/dot.function _Skel() " for any files norm 1G0 let ext = expand('%:e') let dotfile = $VIM . '/vimfiles/skel/dot.' . ext exec 'r ' . dotfile norm 1Gdd endfunction function HSkel() " for .h files call _Skel() let HGUARG = toupper(expand('%:t:r')) exec 'silent %s/%FILE%/' . HGUARG . '/g' norm G- endfunction function Skel() let ext = expand('%:e') if ext == 'h' call HSkel() elseif ext == 'w' call _Skel() endif endfunction command! -buffer Skel :call Skel()
For example, I have in vimfiles/skel/dot.h:
/* * $Id$ */ #ifndef _%FILE%_H #define _%FILE%_H #endif /* !_%FILE%_H*/
and after creation of some.h I call :Skel and get:
/* * $Id$ */ #ifndef _SOME_H #define _SOME_H #endif /* !_SOME_H*/
Комментариев нет:
Отправить комментарий
Thanks for your posting!