如何在给定文件扩展名的vim中定义默认初始文件?

Fer*_*isi 4 vim

每次我写一个新的python程序,我发现自己一遍又一遍地写相同的初始行:

#!/usr/bin/env python
'''
Description of the program
'''
import always, the, same, libraries

def helper_function(helpers_args):
'''
A function that is called in get_main_output, but that someone might want to import too.
'''
    continue

def get_main_output(program_arguments):
'''
Description of the main function
'''
    continue

if __name__ == '__main__':
    output = get_main_output(sys.argv)
Run Code Online (Sandbox Code Playgroud)

我不想每次都手工完成.我希望vim每次打开带有扩展名的不存在的文件时都会向我显示此文件.py,以便我可以根据需要对其进行修改,然后将其保存到我新创建的源文件中.

我怎样才能做到这一点?

如果答案已经在某处,请道歉.我以为会是,但我无法在任何地方找到它.

Gil*_*not 6

/etc/vim/vimrc/etc/vimrc~/.vimrc

" python skeleton
autocmd BufNewFile *.py 0r ~/.vim/skeleton.py
Run Code Online (Sandbox Code Playgroud)

骨架文件:

~/.vim/skeleton.py
Run Code Online (Sandbox Code Playgroud)

将原始帖子中的python代码作为简单用户放在此文件中

Vim文档:

skeleton/templateautocmd.txt