Welcome 微信登录
编程资源 图片资源库 蚂蚁家优选 PDF转换器

首页 / 操作系统 / Linux / Vim 创建Python脚本时候自动补全解释器和编码方法

在用户家目录下创建vimrc文件,然后将如下内容添加进来:function HeaderPython()call setline(1, "#!/usr/bin/env python")call append(1, "#-*- coding:utf8 -*-")normal Gnormal onormal oendfautocmd bufnewfile *.py call HeaderPython()保存退出即可比如我用的是root用户,那么我创建过程如下:vim ~/.vimrcfunction HeaderPython()call setline(1, "#!/usr/bin/env python")call append(1, "#-*- coding:utf8 -*-")normal Gnormal onormal oendfautocmd bufnewfile *.py call HeaderPython()保存后退出然后在任何目录下直接vim 文件名即可更多Vim相关教程见以下内容:把VIM打造成一个简单实用的IDE http://www.linuxidc.com/Linux/2011-06/37032.htmVim学习指南 http://www.linuxidc.com/Linux/2013-08/89096.htm快速学会 Vi编辑器 http://www.linuxidc.com/Linux/2013-08/88586.htm强大的Vim 编辑器 http://www.linuxidc.com/Linux/2013-07/87544.htm在CentOS 6.2上搭建Vim开发环境 http://www.linuxidc.com/Linux/2013-07/87363.htmCentOS 5.4 安装高亮Vim编辑工具 http://www.linuxidc.com/Linux/2013-06/86508.htmVim技巧分享:C语言设置 http://www.linuxidc.com/Linux/2012-12/77124.htmUbuntu中设置Vim的行号 http://www.linuxidc.com/Linux/2012-12/75485.htmVim编辑器使用基础教程 http://www.linuxidc.com/Linux/2013-05/84031.htm本文永久更新链接地址:http://www.linuxidc.com/Linux/2015-11/124859.htm