vim 环境配置及文件后自动插入模板信息

1.创建环境配置文件

全局配置 vim /etc/vimrc
用户配置 vim ~/.vimrc

2.写入想要的配置

set paste        "复制保留格式  关闭:nopaste
set history=1000 "记录历史行数
set tabstop=4 "tab缩进4字符 默认为8 ts
set cul "光标标示行所在线 关闭:nocursorline
syntax on "语法高亮 关闭:off


"set lit "显示换行符 关闭:nolit
"set hlsearch "高亮搜索 关闭:nohl(nohlsearch)
"set ff=dos "文件格式 修改:ff=unix ff(fileformat)
"set et "空格代替Tab 关闭:noexpandtab
"set number "行号 关闭:nonu(nonumber)
"set ignorecase "忽略大小写 关闭:noic
"set ai "autoindent自动缩进结构 关闭:noai autoindent
"set smartindent "smartindent自动缩进结构
"set shiftwidth=4 "设置第二行缩进4字符 <<左缩进 >>右缩进
"set textwidth=65 "文本宽度 左向右65字符
"set wrapmargin=15 "文本宽度 右向左15字符
"set key=passord "加密 关闭:key=
"set nocompatible "关闭兼容模式 开启后:配vi所以关闭 开启兼容:compatible
"set background=dark "背景色
"set showmatch "光标回到符号中间
"set guioptions-=T "去除Gvim工具栏
"set ruler "右下角显示光标所在位置参数
"set nohls "关闭高亮匹配
"set is "即时搜索 高亮显示 关闭:noincsearch
"filetype on "检测文件类型
"set fileencodings=utf-8 "启动时检测并适配编码 如:=ucs-bom,utf-8,cp936


function AddFileInformation_sh()
let infor = "#!/bin/bash\n"
\."\n"
\."#***************************************************************************\n"
\."# * \n"
\."# * @文件: ".expand("%")." \n"
\."# * @作者: Fa \n"
\."# * @时间: ".strftime("%Y-%m-%d %H:%M")." \n"
\."# * @版本: 1.0 \n"
\."# * @类型: Shell script \n"
\."# * \n"
\."#************************************************************************** \n"
\."\n"
\."\n"
silent put! =infor
endfunction
autocmd BufNewFile *.sh call AddFileInformation_sh()

function AddFileInformation_py()
let infor = "#!/usr/bin/env python\n"
\."# -*- coding: utf-8 -*-\n"
\."#************************************************************************* \n"
\."# * @文件: ".expand("%")." \n"
\."# * @作者: Fa \n"
\."# * @时间: ".strftime("%Y-%m-%d %H:%M")." \n"
\."# * @版本: 1.0 \n"
\."# * @类型: Python script \n"
\."#************************************************************************* \n"
\."\n"
\."import os,sys"
\."\n"
\."print u'''中文'''\n"
\."\n"
\."exit()"
silent put! =infor
endfunction
autocmd BufNewFile *.py call AddFileInformation_py()