Auto headers when opening a new python file using vim

Possible duplicate:
How can I automatically add skeleton code when creating a new file using vim

I searched googled and searched on SO to create automatic headers when creating a new python file. I was hoping to find something with snipMate but could not find anything. I use bash -suport , perl-support which provide this functionality and how it is. If this can help, I am also a python-mode user

  • Is there a way to generate automatic headers using snipMate?
  • If not, where can I find examples?

I would like something like this:

#!/usr/bin/python #-*- coding: utf-8 -*- #=============================================================================== # # FILE: test.py # # USAGE: ./test.py # # DESCRIPTION: # # OPTIONS: --- # REQUIREMENTS: --- # BUGS: --- # NOTES: --- # AUTHOR: YOUR NAME (), # ORGANIZATION: # VERSION: 1.0 # CREATED: 09/12/2012 13:38:51 # REVISION: --- #=============================================================================== def main(): """docstring for main""" pass 

Thanks so much for reading

+8
python vim header snipmate autocmd
source share
1 answer

You do not need Snipmate for this. Save the header in a file, and then add the following to your .vimrc :

 au BufNewFile *.py 0r /where/you/saved/your/header.template 

This automatically inserts your header for each .py file.

If you want a header with variables (e.g. changing dates, version numbers, file names, etc.), see this article and this for further help. But there is another plugin (s) to help you.

+12
source share

All Articles