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

bash, python, vim

Solution

Or if you want to avoid plugins:

autocmd bufnewfile *.py 0r /path/to/python_default.py

Problem

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

Original source