您的位置:首页 > 其它

Gvim的配置文件vimrc_example.vim

2013-10-30 14:03 281 查看
" 插入括号时,短暂地跳转到匹配的对应括号

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 FileType
html,text,php,vim,c,java,xml,bash,shell,perl,python setlocal
textwidth=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> :call
CompileRunGcc()<CR>

func! CompileRunGcc()

exec "w"

exec "!gcc % -o %<"

exec "! ./%<"

endfunc

" C++的编译和运行

map <F6> :call
CompileRunGpp()<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')|set
ambiwidth=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"set
number                 
" 显示行号

"set
cursorline            
" 突出显示当前行

syntax
on                  
" 自动语法高亮

set
hlsearch               
" 搜索时高亮显示被找到的文本

"set
smartindent            
" 为C程序提供自动缩进

" 使用C样式的缩进

set cindent

" 制表符为4

set tabstop=4

" 统一缩进为4

set softtabstop=4

set shiftwidth=4

" C的编译和运行

map <F5> :call
CompileRunGcc()<CR>

func! CompileRunGcc()

exec "w"

exec "!gcc % -o %<"

exec "! ./%<"

endfunc

" C++的编译和运行

map <F6> :call
CompileRunGpp()<CR>

func! CompileRunGpp()

exec "w"

exec "!g++ % -o %<"

exec "! ./%<"

endfunc
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: