Vim Tips Wiki
(First pass (categories ; code ; references ; dodgy))
(remove old content)
 
(8 intermediate revisions by 4 users not shown)
Line 1: Line 1:
  +
#REDIRECT [[Use eval to create dynamic templates]]
{{review}}
 
{{Tip
 
|id=375
 
|title=autocmd for skeleton html file (BufFileNew)
 
|created=November 25, 2002 12:23
 
|complexity=basic
 
|author=Dan Allen
 
|version=5.7
 
|rating=19/7
 
|text=
 
How about starting your new html document with a nice shiny skeleton!
 
}}
 
 
Add this in your autocmd section in your .vimrc file
 
 
" Start with an html skeleton docuement when opening a new *.html file
 
au BufNewFile *.html | execute "normal! :set ai!\<kEnter>i<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\<kEnter><html>\<kEnter> <head>\<kEnter> <style>\<kEnter> </style>\<kEnter> <script>\<kEnter> </script>\<kEnter> </head>\<kEnter> <body>\<kEnter> </body>\<kEnter></html>\<ESC>:set ai\<kEnter>gg"
 
 
== References ==
 
*{{help|BufNewFile}}
 
*{{help|:execute}}
 
*{{help|:normal}}
 
 
'''See also:'''
 
*{{help|template}}
 
 
== Comments ==
 
The tip added endlines where they are not supposed to be...please remove all endlines so that the command list just a single line.
 
 
bigredlinux at yahoo.com
 
, November 25, 2002 12:26
 
----
 
Slight Variant (without tabs/spaces)
 
au BufNewFile *.html | execute "normal! :\<kEnter>i\<html>\<kEnter><head>\<kEnter><title>title</title>\<kEnter><script>\<kEnter></script>\<kEnter></head>\<kEnter><body>\<kEnter></body>\<kEnter></html>\<ESC>gg"
 
 
david--AT--tvis.co.uk
 
, November 26, 2002 2:36
 
----
 
I added some spaces to make the indentation a little prettier:
 
au BufNewFile *.html | execute "normal! :\<kEnter>i\<html>\<kEnter> <head>\<kEnter> <title></title>\<kEnter> <script language=\"javascript\">\<kEnter> </script>\<kEnter> </head>\<kEnter> <body>\<kEnter> </body>\<kEnter></html>\<ESC>gg"
 
 
 
perry.tew cibavision.novartis.com
 
, October 21, 2003 11:59
 
----
 
TODO: Make a choice/fix the snippets. None of the code snippets really looked good in my environment (because of indenting issues). Morevover all three have a little something the others don't have. (May I say using a template-file loader/expander provides templates easier to tweak?... :-/ -> {{help|template}}).
 
 
Anyway, I'm quite sure there are many template/snippets tips out there. Let's start by finding them all.
 
 
--[[User:Luc Hermitte|Luc Hermitte]] 18:07, 26 July 2007 (UTC)
 
<!-- parsed by vimtips.py in 0.664496 seconds-->
 
 
[[Category:Automated_Text_Insertion]]
 
[[Category:HTML]]
 
[[Category:Dodgy]]
 

Latest revision as of 12:52, 14 August 2012