Vim Tips Wiki
(Reviewed: Comments taken into account, added to categories A.T.I. and HTML)
m (typo)
Line 16: Line 16:
   
 
I want the files <tt>header.html</tt> and <tt>footer.html</tt> to be inserted on my page, you can do this with the following command:
 
I want the files <tt>header.html</tt> and <tt>footer.html</tt> to be inserted on my page, you can do this with the following command:
command! -range=% Refile &lt;line1&gt;,&lt;line2&gt;g/^&#35;revile=/exe ":r " . strpart(getline("."), 8) | normal! kdd
+
command! -range=% Refile &lt;line1&gt;,&lt;line2&gt;g/^&#35;refile=/exe ":r " . strpart(getline("."), 8) | normal! kdd
 
" 'Read_vim' / Revise by reading in file templates.
 
" 'Read_vim' / Revise by reading in file templates.
 
" Get the string part after the = sign, on line(s) which
 
" Get the string part after the = sign, on line(s) which

Revision as of 18:58, 26 July 2007

Previous TipNext Tip

Tip: #624 - Insert template files into buffer

Created: December 18, 2003 4:35 Complexity: intermediate Author: A.L Marin Version: 5.7 Karma: 7/6 Imported from: Tip#624

While editing HTML I want to use template files to be expanded on my html pages. Say for example I have something like this on my html file:

#refile=path/templates/header.html
<p>html code here</p> 
<p>more html code here...</p> 
#refile=path/templates/footer.html

I want the files header.html and footer.html to be inserted on my page, you can do this with the following command:

command! -range=% Refile <line1>,<line2>g/^#refile=/exe ":r " . strpart(getline("."), 8) | normal! kdd 
" 'Read_vim' / Revise by reading in file templates. 
" Get the string part after the = sign, on line(s) which 
" *begin* with #revim= , and use that to read in said file 
" -------------------- (kdd deletes the # line; put comments in templates). 


Notes

  • The filenames are not embedded in comments because they could be easily overlooked later.
  • refile stands for reference file

Comments