加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

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

发布时间:2020-12-15 21:36:05 所属栏目:安全 来源:网络整理
导读:每次我写一个新的 python程序,我发现自己一遍又一遍地写相同的初始行: #!/usr/bin/env python'''Description of the program'''import always,the,same,librariesdef helper_function(helpers_args):'''A function that is called in get_main_output,but t
每次我写一个新的 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)

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

我怎样才能做到这一点?

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

解决方法

在/ etc / vim / vimrc或/ etc / vimrc或?/ .vimrc中

" python skeleton
autocmd BufNewFile *.py 0r ~/.vim/skeleton.py

骨架文件:

~/.vim/skeleton.py

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

Vim文档:

autocmd.txtskeleton/template

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读