Autocmd for skeleton html file
From Vim Tips Wiki
Tip 375 Previous Next Created: November 25, 2002 Complexity: basic Author: Dan Allen Version: 5.7
How about starting your new html document with a nice shiny skeleton! Add this in your autocmd section in your vimrc:
" Start with an html skeleton document 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"
[edit] References
[edit] Comments
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"
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"
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.
