View previous topic :: View next topic |
Author |
Message |
Poloch n00b
Joined: 13 Mar 2005 Posts: 39
|
Posted: Mon May 14, 2007 12:35 am Post subject: New file automatically filled with a skeleton in vim... |
|
|
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 |
|
|
vandien Tux's lil' helper
Joined: 03 May 2006 Posts: 137
|
Posted: Mon May 14, 2007 2:25 am Post subject: |
|
|
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 |
|
|
Poloch n00b
Joined: 13 Mar 2005 Posts: 39
|
Posted: Tue May 15, 2007 11:53 pm Post subject: |
|
|
Thanks a lot.
That's perfect for my needs! _________________ May the Holy Marmot be with me!!! |
|
Back to top |
|
|
dkure n00b
Joined: 20 Apr 2004 Posts: 51 Location: Sydney, Australia
|
Posted: Fri May 18, 2007 2:21 am Post subject: |
|
|
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 |
|
Back to top |
|
|
|
|
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
|
|