" 显示行号
set number
" 历史纪录
set history=1000
" 输入的命令显示出来,看的清楚些
set showcmd
" 启动显示状态行1,总是显示状态行2
set laststatus=2
" 语法高亮显示
syntax on
set fileencodings=utf-8,gb2312,gbk,cp936,latin-1
set fileencoding=utf-8
set termencoding=utf-8
set fileformat=unix
set encoding=utf-8
" 配色方案
colorscheme desert
" 指定配色方案是256色
set t_Co=256
" 用空格代替tab
set expandtab
" 设置显示制表符的空格字符个数,改进tab缩进值,默认为8,现改为4
set tabstop=4
" 设定自动缩进为4个字符,程序中自动缩进所使用的空白长度
set shiftwidth=4
" 设置帮助文件为中文(需要安装vimcdoc文档)
set helplang=cn
" 显示匹配的括号
set showmatch
" delete
set backspace=2
" Uncomment the following to have Vim jump to the last position when
" reopening a file
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
" 显示行号
set number
" 历史纪录
set history=1000
" 输入的命令显示出来,看的清楚些
set showcmd
" 启动显示状态行1,总是显示状态行2
set laststatus=2
" 语法高亮显示
syntax on
set fileencodings=utf-8,gb2312,gbk,cp936,latin-1
set fileencoding=utf-8
set termencoding=utf-8
set fileformat=unix
set encoding=utf-8
" 配色方案
colorscheme desert
" 指定配色方案是256色
set t_Co=256
" 用空格代替tab
set expandtab
" 设置显示制表符的空格字符个数,改进tab缩进值,默认为8,现改为4
set tabstop=4
" 设定自动缩进为4个字符,程序中自动缩进所使用的空白长度
set shiftwidth=4
" 设置帮助文件为中文(需要安装vimcdoc文档)
set helplang=cn
" 显示匹配的括号
set showmatch
" delete
set backspace=2
" Uncomment the following to have Vim jump to the last position when
" reopening a file
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
autocmd BufNewFile *.go,*.c,*.cpp,*.sh,*.py,*.java exec ":call SetTitle()"
"定义函数SetTitle,自动插入文件头
func SetTitle()
"如果文件类型为.c或者.cpp文件
if (&filetype == 'c' || &filetype == 'cpp' || &filetype == 'go')
call setline(1, "/*************************************************************************")
call setline(2, "\ @Author: xihuaxiao")
call setline(3, "\ @Created Time : ".strftime("%c"))
call setline(4, "\ @File Name: ".expand("%"))
call setline(5, "\ @Description:")
call setline(6, " ************************************************************************/")
call setline(7,"")
endif
"如果文件类型为.sh文件
if &filetype == 'shell'
call setline(1, "\#!/bin/sh")
call setline(2, "\# Author: xihuaxiao")
call setline(3, "\# Created Time : ".strftime("%c"))
call setline(4, "\# File Name: ".expand("%"))
call setline(5, "\# Description:")
call setline(6,"")
endif
"如果文件类型为.py文件
if &filetype == 'python'
call setline(1, "\#!/usr/bin/env python")
call setline(2, "\# -*- coding=utf8 -*-")
call setline(3, "\"\"\"")
call setline(4, "\# Author: xihuaxiao")
call setline(5, "\# Created Time : ".strftime("%c"))
call setline(6, "\# File Name: ".expand("%"))
call setline(7, "\# Description:")
call setline(8, "\"\"\"")
call setline(9,"")
endif
"如果文件类型为.java文件
if &filetype == 'java'
call setline(1, "//coding=utf8")
call setline(2, "/**")
call setline(3, "\ *\ @Author: xihuaxiao")
call setline(4, "\ *\ @Created Time : ".strftime("%c"))
call setline(5, "\ *\ @File Name: ".expand("%"))
call setline(6, "\ *\ @Description:")
call setline(7, "\ */")
call setline(8,"")
endif
endfunc
" 自动将光标移动到文件末尾
autocmd BufNewfile * normal G