Thursday, February 6, 2014

Re: Adding a file name to a template

On 2014-02-05 22:42, brandon wallace wrote:
> I would like to know if I can put the file name into the template
> automatically. This is what I have in my .vimrc to create the
> template:
>
> /augroup filetype_html
> autocmd!
> autocmd BufNewFile * silent! 0r $HOME/.vim/templates/%:e.tpl
> augroup END/

You can create a place-holder in your .tpl file, such as "%FILENAME%"
and then make your statement

augroup filetype_html
autocmd!
autocmd BufNewFile * silent! 0r $HOME/.vim/templates/%:e.tpl
autocmd BufNewFile * silent! %s/%FILENAME%/\=expand('%')/g
augroup END

It Works For Me™ :-)

-tim



--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment