Вот мой шаблон C ++ файлов:
/*****************************************************************************
* @file <file_name>
*
* @date <date>
* @author John Doe
* @email jdoe@yourcompany.com
*
* @brief
*
* @detail
*
*****************************************************************************/
А вот что у меня внутри ~/.vimrc
:
" Reads the template file replacing the tags by the actual
" information and insert the result at the beginning of the buffer. At
" the end, creates two blank lines at the end of the file and
" position the cursor at the first one.
function! s:insert_description()
let template = $HOME . "/.vim/template/cpp.template"
let file_name = expand("%:t") " Get file name without path
let date = strftime("%Y") " Get the current year in format YYYY
let i = 0
for line in readfile(template)
let line = substitute(line, "<file_name>", file_name, "ge")
let line = substitute(line, "<date>", date, "ge")
call append(i, line)
let i += 1
endfor
execute "normal! Go\<Esc>k"
endfunction
autocmd BufNewFile *.{c++,cpp,cc,c,h,hpp} call <SID>insert_description()
В основном я читаю файл шаблона, заменяя тегис актуальной информацией и вставьте результат в начале вновь созданного файла.Функция s:insert_description()
вызывается всякий раз, когда vim создает новый файл.Это устанавливается autocmd
в последней строке.
Вы можете основываться на этом коде и создать эквивалент для python.