vim 配置文件
2014-08-24 21:33
253 查看
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
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
相关文章推荐
- 史上最强的Vim 配置文件(修正版)
- 最经典的Vim 配置文件(供参考学习)
- linux下的VIM配置文件
- 史上最强的Vim 配置文件
- 我的vim的配置文件.vimrc的内容(适用于vim7.2)
- Vim的行号、语法显示等设置,即.vimrc文件的配置
- vim 配置文件
- RHCE课程-RH033Linux基础笔记六之编辑工具VIM、网络配置、进程优先、日志文件简介 推荐
- RHCE课程-初级部分6、编辑工具VIM,网络配置,进程优先,日志文件简介。
- vim配置文件收集(作为c/c++和脚本开发的环境)
- 对vim配置文件的编辑
- 史上最强的Vim 配置文件(2008-3-21修正版)
- 我的VIM配置文件
- vim配置文件例子(.vimrc)
- vim配置文件 .vimrc
- Vim的行号、语法显示等设置,即.vimrc文件的配置
- vim配置技巧——在vim中使用autocmd命令在保存文件时自动插入最后修改日期和时间
- 我的vim配置文件
- vim配置文件.vimrc
- 我的Vim配置文件