LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-09-2006, 09:00 PM   #1
Penguin of Wonder
Senior Member
 
Registered: Sep 2005
Location: West Virginia
Distribution: Gentoo
Posts: 1,249

Rep: Reputation: 45
Question Vim cc file template


Is it possiable to get vim to automatically write certain things in new files, like a new header and footer. Stuff that would be inspecific to the type of file (main program, header, etc.) or even the file's eventual code type (c, c++, ruby, python, etc.). For example

Quote:
/***********************************************
* [LEFT BLANK FOR PROGRAM DISCRIPTION]
*
* My name - my email address
***********************************************/



[BLANK SPACE FOR EVENTUAL CODE]




/* Created in vim compiled with GCC 4.1.1 */
Any ideas? And since I'm thinking about it, any ideas on how to improve my template (even if I can't make it automatic) would be greatly appreciated as well! Thanks in advance.
 
Old 10-09-2006, 10:20 PM   #2
Moy Easwaran
Member
 
Registered: Dec 2004
Distribution: Slackware, OpenBSD
Posts: 44

Rep: Reputation: 19
Put the following in your .vimrc:
Code:
au BufNewFile *.c 0read ~/.template.c
The 0 just tells it to insert at the beginning instead of starting at line 2. Also, you might want to look up autocmd. And finally, vim.org also has some related tips; google site:vim.org "new file" template

Moy

(Edited to remove BufRead.)

Last edited by Moy Easwaran; 10-09-2006 at 11:10 PM.
 
Old 10-09-2006, 11:20 PM   #3
Penguin of Wonder
Senior Member
 
Registered: Sep 2005
Location: West Virginia
Distribution: Gentoo
Posts: 1,249

Original Poster
Rep: Reputation: 45
Thanks for the reply Moy Easwaran. I will look up the given information, and report back if I have questions. Again, thank you.
 
Old 10-10-2006, 01:14 PM   #4
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 43
At the risk of seeming self-serving, I've got a little page on my website about just such things, a little more general than Moy's good advice:

http://www.metasyntax.net/index.php?...ge=boilerplate
 
Old 10-10-2006, 05:28 PM   #5
Penguin of Wonder
Senior Member
 
Registered: Sep 2005
Location: West Virginia
Distribution: Gentoo
Posts: 1,249

Original Poster
Rep: Reputation: 45
Thanks for the link taylor. I read through your site, pretty nice, better than mine... anyway. I cannot find anything on boilerplates, though I did find a lot of references to skeleton templates. I haven't actually tried to use any of them right yet as I'm in the middle of several good sized assignment for my C++ class. The last thing I need to do is screw up vim.
 
  


Reply

Tags
vim



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with rpmbuild and template.spec file abefroman Linux - Software 0 11-27-2005 12:18 AM
Template class with a template member... Nicholas Bishop Programming 3 02-21-2005 08:27 PM
How do I make a template file in GIMP for Dreamweaver mx? arctic123 Linux - Software 2 01-27-2005 08:15 AM
Find variable in template file replace w/date+ and save as jmanjohn61 Linux - General 14 12-13-2004 06:49 AM
Dreamweaver file in vim NOT_Skeletor Linux - Software 1 08-03-2004 04:00 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration