Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bash or vim alias/command to use a certain template when creating Python files?

Tags:

python

bash

vim

I was wondering if it is possible to insert something in .bashrc or .vimrc so that whenever I create a new Python file via vim it automatically creates a file with this already inserted before I edit it:

#!/usr/bin/env python

import sys

if __name__ == '__main__':

A vast majority of my Python scripts use those lines, and if there is a way to include those for every newly created Python file I make that would be great.

Thanks! -kstruct

like image 749
adelbertc Avatar asked May 10 '12 21:05

adelbertc


1 Answers

Or if you want to avoid plugins:

autocmd bufnewfile *.py 0r /path/to/python_default.py
like image 108
jimw Avatar answered Oct 13 '22 01:10

jimw