You are not logged in.
Hey guys I'm really unsure why my vim templates won't load.
My templates are stored below in /home/miles/.vim/skel/<mytemplatefile>
[skel]> pwd
/home/miles/.vim/skel
[skel]> ls -l
total 4
-rwxrwxrwx 1 miles users 234 Oct 30 22:17 tmpl.cAnd I tried to implementations to get template to load by appending these lines to my ~/.vim/vimrc
"To load template
" The one below is another implmentation that I had tried.
"autocmd BufNewFile *.c 0r ~/.vim/skel/tmpl.c
autocmd! BufNewFile * silent! 0r $HOME/.vim/skel/tmpl.%:eI have no idea why template won't load for new C files, doesn't seem like anybody else on the internet has this problem.... Thanks.
Last edited by Jabrick (2012-11-04 00:08:04)
Offline
Try this:
autocmd BufNewFile *.c execute ':r ~/.vim/skel/tmpl.c'Offline
Hey thank you for the advice, but it is still not working.
I am beginning to think maybe I am misunderstanding my problem.
What I am expecting to is do something like
vim new_file.cWhere "new_file.c" does not already exist, and it should auto load my template.
This is not currently happening.
Am I misunderstanding my problem or is there something wrong with my vimrc?
I'll post my config on pastebin: http://pastebin.com/n8ZM3kK9
Offline
I don't know what to tell you. When I put that line in my .vimrc and added a ~/.vim/skel/tmpl.c file to my system, it would read that file into the current buffer when I did
$ vim new_file.cif new_file.c didn't exist in $PWD.
I looked at your .vimrc and didn't see anything, but I'm far from a vim expert. One thing, that line I posted last time resulted in an extra '\n' appended to tmpl.c. The following works for me, though:
autocmd BufNewFile *.c execute ':0r ~/.vim/skel/tmpl.c'Sorry I don't see what's causing your problem.
Offline
@rockin turle
Thank you for your honesty.
I added the line you suggested into my /etc/vimrc (replacing the ~ with appropriate home directory) and it works. I tried afterwards changing the name of my ~/.vim/vimrc file, and it still loads the presets I had there. Not sure exactly whats going on I will have to do some more digging, but for now I have a work around. Thank you for your help.
Offline