vim 配置文件

vim的配置文件如下_vimrc:

set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin

set diffexpr=MyDiff()
function MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
let eq = ''
if $VIMRUNTIME =~ ' '
if &sh =~ '\<cmd'
let cmd = '""' . $VIMRUNTIME . '\diff"'
let eq = '"'
else
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
endif
else
let cmd = $VIMRUNTIME . '\diff'
endif
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
endfunction

set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
colorscheme torte

set nu " 显示行号
set foldenable " 允许折叠
set foldmethod=manual " 手动折叠
set background=dark "背景使用黑色
set ts=4 "(注:ts是tabstop的缩写,设TAB宽4个空格)
set expandtab
set smartindent
set shiftwidth=4

set guifont=consolas:h12:cANSI

"进行版权声明的设置
"添加或更新头
map <F4> :call TitleDet()<cr>'s
function AddTitle()
call append(0,"/*===============================================")
call append(1,"# Author: RollerCoaster")
call append(2,"# Last modified:".strftime("%Y-%m-%d %H:%M"))
call append(3,"# Filename: ".expand("%:t"))
call append(4,"# Description: ")
call append(5,"=================================================*/")
echohl WarningMsg | echo "Successful in adding the copyright." | echohl None
endf
"更新最近修改时间和文件名
function UpdateTitle()
normal m'
execute '/# *Last modified:/s@:.*$@\=strftime(":%Y-%m-%d %H:%M")@'
normal ''
normal mk
execute '/# *Filename:/s@:.*$@\=":".expand("%:t")@'
execute "noh"
normal 'k
echohl WarningMsg | echo "Successful in updating the copy right." | echohl None
endfunction
"判断前10行代码里面,是否有Last modified这个单词,
"如果没有的话,代表没有添加过作者信息,需要新添加;
"如果有的话,那么只需要更新即可
function TitleDet()
let n=1
"默认为添加
while n < 7
let line = getline(n)
if line =~ '^\#\s*\S*Last\smodified:\S*.*$'
call UpdateTitle()
return
endif
let n = n + 1
endwhile
call AddTitle()
endfunction

"代码补全
set completeopt=preview,menu
"从不备份
set nobackup

 

posted on 2014-08-24 21:33  BestNow  阅读(313)  评论(0编辑  收藏  举报

导航