Gvim的配置文件vimrc_example.vim

来源:互联网 发布:网络保密十不准 编辑:程序博客网 时间:2024/04/30 23:12

" 插入括号时,短暂地跳转到匹配的对应括号
set showmatch
" 使用 murphy 调色板
" set nocompatible
" 侦测文件类型
filetype on
" 设定文件浏览器目录为当前目录
set bsdir=buffer
set autochdir
" 设置文件编码
set fenc=utf-8
" 设置文件编码检测类型及支持格式
set fencs=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
" 指定菜单语言
set langmenu=zh_CN.UTF-8
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
" 设置语法高亮度
set syn=cpp
"显示行号
set nu!
" 查找结果高亮度显示
set hlsearch
" tab宽度
set tabstop=4
set cindent shiftwidth=4
set autoindent shiftwidth=4
" C/C++注释
set comments=://
" 修正自动C式样注释功能 <2005/07/16>
set comments=s1:
autocmd FileTypehtml,text,php,vim,c,java,xml,bash,shell,perl,python setlocaltextwidth=100
autocmd Filetype html,xml,xsl source$VIMRUNTIME/plugin/closetag.vim
autocmd BufReadPost *
if line("'"") > 0 &&line("'"") <= line("$") |
exe "normal g`"" |
endif
endif " has("autocmd")

" F5编译和运行C程序,F6编译和运行C++程序
" 请注意,下述代码在windows下使用会报错
" 需要去掉./这两个字符

" C的编译和运行
map <F5> :callCompileRunGcc()<CR>
func! CompileRunGcc()
exec "w"
exec "!gcc % -o %<"
exec "! ./%<"
endfunc

" C++的编译和运行
map <F6> :callCompileRunGpp()<CR>
func! CompileRunGpp()
exec "w"
exec "!g++ % -o %<"
exec "! ./%<"
endfunc

" 能够漂亮地显示.NFO文件
set encoding=utf-8
function! SetFileEncodings(encodings)
let b:myfileencodingsbak=&fileencodings
let &fileencodings=a:encodings
endfunction
function! RestoreFileEncodings()
let &fileencodings=b:myfileencodingsbak
unlet b:myfileencodingsbak
endfunction

au BufReadPre *.nfo call SetFileEncodings('cp437')|setambiwidth=single
au BufReadPost *.nfo call RestoreFileEncodings()

" 高亮显示普通txt文件(需要txt.vim脚本)
au BufRead,BufNewFile *  setfiletype txt

" 用空格键来开关折叠
set foldenable
set foldmethod=manual
nnoremap <space>@=((foldclosed(line('.')) < 0) ? 'zc' :'zo')<CR>

" minibufexpl插件的一般设置
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplMapWindowNavArrows = 1
let g:miniBufExplMapCTabSwitchBufs = 1
let g:miniBufExplModSelTarget = 1


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
我设置的.vimrc

dfd"setnumber                 " 显示行号
"setcursorline            " 突出显示当前行
syntaxon                  " 自动语法高亮
sethlsearch               " 搜索时高亮显示被找到的文本
"setsmartindent            " 为C程序提供自动缩进

" 使用C样式的缩进
set cindent

" 制表符为4
set tabstop=4

" 统一缩进为4
set softtabstop=4
set shiftwidth=4



" C的编译和运行
map <F5> :callCompileRunGcc()<CR>
func! CompileRunGcc()
exec "w"
exec "!gcc % -o %<"
exec "! ./%<"
endfunc

" C++的编译和运行
map <F6> :callCompileRunGpp()<CR>
func! CompileRunGpp()
exec "w"
exec "!g++ % -o %<"
exec "! ./%<"
endfunc

原创粉丝点击