Visit the LQ Articles and Editorials section
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 03-28-2004, 02:01 AM   #1
Registered: Feb 2004
Posts: 66

Rep: Reputation: 15
Arrow Wanna change my VIM configuration


I wanna change my vim configuration so that every time i open
a new file with vim saying vim 1.c ..The first few lines should
be as

* Something Here
date created and las modified date
and about the information of the file like no of lines etc...

ANy help will be greatly appreciated

Thanks in anticipation
Old 04-19-2004, 08:24 AM   #2
Senior Member
Registered: Sep 2003
Location: UK
Distribution: Debian
Posts: 1,215
Blog Entries: 2

Rep: Reputation: 49
How about writing a small bash script to write the stuff with 'date' and 'wc' and so on and then putting a thing in .vimrc to append it to the top of every file. Just a thought, have never done anything like.

Old 04-19-2004, 10:22 AM   #3
Registered: Jul 2003
Location: CT, USA
Distribution: Debian Sarge (server), Etch (work/home)
Posts: 601

Rep: Reputation: 31
Here's a start:
touch && chmod 0755
then put the following in that file:
for filename in $*
    echo "/* this comment at the top" >> $filename
    echo "   this one too!" >> $filename
    echo "   the date is `date`" >> $filename
    echo "*/" >> $filename

Last edited by johnMG; 04-19-2004 at 10:27 AM.
Old 04-19-2004, 08:29 PM   #4
Registered: May 2003
Location: NC, USA
Distribution: Slackware 14.0
Posts: 94

Rep: Reputation: 15

echo "/* comment one " > $1
echo "*  date created: `date`" >> $1
echo "*  comment last */" >> $1

vi $1
but only works on first file.

Last edited by naflan; 04-19-2004 at 08:32 PM.
Old 04-19-2004, 09:34 PM   #5
Registered: Mar 2004
Location: Massachusetts
Distribution: Debian
Posts: 557

Rep: Reputation: 42
You could try adding this to your .vimrc:
autocmd BufNewFile *.c 0r!new_c_file
and adding this file (named new_c_file in my example) somewhere in your PATH:
echo -n "/*
 * Hello, I'm a new C file
 * Begin date: "
echo " */"
This only inserts the text when you're editing a *new* (previously nonexistant) file ending in .c

The manual suggests putting autocmd! before the autocmd line in your .vimrc, as there are apparently circumstances where the .vimrc could be sourced twice. autocmd! drops all previously set autocmds so you don't set one up twice.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
i wanna change my KDM theme crocodilu Slackware 12 07-13-2005 03:12 AM
Question about VIM configuration ICO Linux - General 4 01-06-2004 08:41 PM
Configuration for VIM editor ICO Linux - General 5 08-02-2003 09:34 PM
Wanna change login screen Xris718 Linux - General 10 05-13-2003 12:34 AM
I wanna change from Gnome to Windowmaker Ekim Gram Linux - Newbie 3 05-08-2003 11:39 PM

All times are GMT -5. The time now is 05:43 PM.

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