Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
New file automatically filled with a skeleton in vim...
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
Poloch
n00b
n00b


Joined: 13 Mar 2005
Posts: 39

PostPosted: Mon May 14, 2007 12:35 am    Post subject: New file automatically filled with a skeleton in vim... Reply with quote

Hello,

I noticed a nice thing with vim, related to the Gentoo system.
If I try to open a non-existent file in /etc/init.d, I get a new file, already pre-filled with a Gentoo init script skeleton:

For instance, if I try a vi /etc/init.d/hdjkzbdkz, I will get a new file with:
Code:

#!/sbin/runscript
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

depend() {

}

start() {

}

stop() {

}

restart() {

}


This is a pretty cool possibility of vi: Apparently, you can pre-fill a file when it is new according to the specific directory one creates it! As I am a big user of vim, this feature is interesting to me (in fact, there was a time, I tried to do something similar with a personal script. It was working, but if I can use an included feature of vim, this would be better).

So does someone knows how this has been customized to do this?
And can I use this feature with prefilled content, depending not only on the directory, but also on the name file (or extension)?

For instance, if I can prefill my latex (*.tex) files with the classical header I most often use. Or better, if I create a file called "letter-*.tex", it will pre-fill it with the header to make a new letter with the letter class and functions; but if the name is "presentation-*.tex", it will fill it differently with a skeleton of presentation using the beamer class.
And if I make a "*.c++" file, I would be happy that it pre-fills a GPL license at the beginning and place the cursor after it, while if it is more precisely main.c++, I would like also a skeleton of main function and place the cursor between its square brackets!

And so on...

Is it possible to customize all these kinds of things?
Thanks.
_________________
May the Holy Marmot be with me!!!
Back to top
View user's profile Send private message
vandien
Tux's lil' helper
Tux's lil' helper


Joined: 03 May 2006
Posts: 137

PostPosted: Mon May 14, 2007 2:25 am    Post subject: Reply with quote

the package that provides that is app-vim/gentoo-syntax.

check out the files in this directory for examples: /usr/share/vim/vimfiles/plugin/
Back to top
View user's profile Send private message
Poloch
n00b
n00b


Joined: 13 Mar 2005
Posts: 39

PostPosted: Tue May 15, 2007 11:53 pm    Post subject: Reply with quote

Thanks a lot.
That's perfect for my needs!
_________________
May the Holy Marmot be with me!!!
Back to top
View user's profile Send private message
dkure
n00b
n00b


Joined: 20 Apr 2004
Posts: 51
Location: Sydney, Australia

PostPosted: Fri May 18, 2007 2:21 am    Post subject: Reply with quote

It would be great if you could publish a few of these configuratons once you have finished. These would be a great help to me as well. Espically the programming GNU stuff :D
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum