Own simple template system in vim - include file -


i've read vim-wiki dynamic templates , want similar, simple "template-system". i've created function:

function! read_template(file)     execute '0r /home/zsolt/.vim/skeletons/'.a:file     %substitute#\[:eval:\]\(.\{-\}\)\[:end:\]#\=eval(submatch(1))#ge     %substitute#\[:read:\]\(.\{-\}\)\[:end:\]#??????#ge endfunction 

i want include file template. eval works how can solve read function? isn't important eval included file.

an example:

main.tex:

\documentclass[a4paper]{article} .... 

exam.tex:

% created [:eval:]strftime('%y. %b. %d.')[:end:] [:read:]/path/of/main/main.tex[:read:] 

i exec read_template("exam.tex") , want exam.tex includes main.tex.

how can this?

you'll need read file , insert contents. cannot use :read (it read entire lines , cannot called within substitution), have use lower-level readfile() vimscript function, this:

%substitute#\[:read:\]\(.\{-\}\)\[:end:\]#\=join(readfile(submatch(1)),"\n")/#ge 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -