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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
10-09-2006, 09:00 PM
|
#1
|
Senior Member
Registered: Sep 2005
Location: West Virginia
Distribution: Gentoo
Posts: 1,249
Rep:
|
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.
|
|
|
10-09-2006, 10:20 PM
|
#2
|
Member
Registered: Dec 2004
Distribution: Slackware, OpenBSD
Posts: 44
Rep:
|
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.
|
|
|
10-09-2006, 11:20 PM
|
#3
|
Senior Member
Registered: Sep 2005
Location: West Virginia
Distribution: Gentoo
Posts: 1,249
Original Poster
Rep:
|
Thanks for the reply Moy Easwaran. I will look up the given information, and report back if I have questions. Again, thank you.
|
|
|
10-10-2006, 01:14 PM
|
#4
|
Member
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892
Rep:
|
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
|
|
|
10-10-2006, 05:28 PM
|
#5
|
Senior Member
Registered: Sep 2005
Location: West Virginia
Distribution: Gentoo
Posts: 1,249
Original Poster
Rep:
|
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.
|
|
|
All times are GMT -5. The time now is 10:36 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|