Code, robots and stuff

Always wanted to have that cool IDE-feature of automatic comments in your newly created source-files but can't stop using vim as your IDE? Now you can have both!
First; create a file named c_template that you put somewhere(I put mine in ~/.vim/templates) that contains the following



 * File Name :

 * Purpose :

 * Creation Date :

 * Last Modified :

 * Created By :




Then, in your ~/.vimrc insert the following somewhere

" To automatically put a comment in a new c-file

autocmd bufnewfile *.c so /home/yourusernamehere/.vim/templates/c_header.txt

autocmd bufnewfile *.c exe "1," . 8 . "g/File Name :.*/s//File Name : " .expand("%")

autocmd bufnewfile *.c exe "1," . 8 . "g/Creation Date :.*/s//Creation Date : " .strftime("%d-%m-%Y")

autocmd Bufwritepre,filewritepre *.c execute "normal ma"

autocmd Bufwritepre,filewritepre *.c exe "1," . 10 . "g/Last Modified :.*/s/Last Modified :.*/Last Modified : " .strftime("%c")

autocmd bufwritepost,filewritepost *.c execute "normal `a"

Now, open a new file called test.c, neat huh? Write some text in it, save it and reopen. Now the Last-Modified : should be right as well, it's like magic!