Wikia

Vim Tips Wiki

Changes: Insert template files into buffer

Edit

Back to page

(Remove html character entities)
(Change <tt> to <code>, perhaps also minor tweak.)
 
Line 3: Line 3:
 
|previous=623
 
|previous=623
 
|next=625
 
|next=625
|created=December 18, 2003
+
|created=2003
 
|complexity=intermediate
 
|complexity=intermediate
 
|author=A.L Marin
 
|author=A.L Marin
Line 20: Line 20:
 
</pre>
 
</pre>
   
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 <code>header.html</code> and <code>footer.html</code> to be inserted on my page, you can do this with the following command:
   
 
<pre>
 
<pre>

Latest revision as of 05:39, July 13, 2012

Tip 624 Printable Monobook Previous Next

created 2003 · complexity intermediate · author A.L Marin · version 5.7


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).

NotesEdit

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

CommentsEdit

Around Wikia's network

Random Wiki