定制.vimrc配置文件

来源:互联网 发布:linux文件打包命令 编辑:程序博客网 时间:2024/05/16 12:53
文件下载点,如有如需要请点击(不需要积分)http://download.csdn.net/detail/iamonlyme/3902685
" vimrc by lewiyon@hotmail.com" last update 2011-12-09" 判断操作系统if (has("win32")||has("win64")||has("win32unix"))    let g:isWin=1else    let g:isWin=0endif"----------------------------------------------------------" 常用格式"----------------------------------------------------------" 习惯用“:”作为命令前缀"let mapleader="," " 快捷加载vimrc文件"map <leader>ss :source $HOME/.vimrc<cr>" 快捷打开编辑vimrc文件"map <silent> <leader>ee :e $HOME/.vimrc<cr>"autocmd! bufwritepost *.vimrc source $HOME/.vimrc" 设置行号set nu" tab转化为4个字符set expandtabset smarttabset shiftwidth=4set tabstop=4" 恢复上次文件打开位置"set viminfo='10,\"100,:20,%,n~/.viminfoif has("autocmd")    autocmd BufReadPost *         \ if line("'\"") > 0 | if line("'\"") <= line("{1}quot;) |        \ exe("norm '\"") | else|exe "norm {1}quot;|        \ endif | endifendif" 关闭兼容模式set nocompatible" 语法高亮syntax enable" 文件类型插件filetype plugin onfiletype indent onset autoindentautocmd BufEnter * :syntax sync fromstart" 显示命令set showcmd" 高亮搜索set hlsearch" 设置当前行高亮set cursorline" 不使用swp文件set noswapfile" 设置记录历史条数set history=200"----------------------------------------------------------" 断行设置"----------------------------------------------------------" 设置光标超过80时折行"set tw=80" 第80列往后加下划线au BufWinEnter * let w:m2=matchadd('Underlined', '\%>' . 80 . 'v.\+', -1)"----------------------------------------------------------" C/C++ 编码设置 "----------------------------------------------------------" 设置自动缩进set autoindent" 设置智能缩进set smartindent" 显示括号配对情况set sm" 打开C/C++风格的自动缩进autocmd FileType c,cpp,cc" 设置注释格式set cindent comments=sr:/*,mb:*,el:*/,:// set cin" 设置缩进风格" t0 表示函数返回值与函数名不在同一行,0表示返回值前空一格set cinoptions=>4,n-2,{4,^-2,:2,=2,g0,h2,p5,t0,+2,(0,u0,w1,m1"----------------------------------------------------------" 状态条总是显示:字节数、列数、行数、当前行等信息"----------------------------------------------------------set laststatus=2set rulerset statusline=\ %{HasPaste()}%<%-15.25(%f%)%m%r%h\ %w\ \ set statusline+=\ \ \ [%{&ff}/%Y] set statusline+=\ \ \ %<%20.30(%{hostname()}:%{CurDir()}%)\ set statusline+=%=%-10.(%l,%c%V%)\ %p%%/%Lfunction! CurDir()    let curdir = substitute(getcwd(), $HOME, "~", "")    return curdirendfunctionfunction! HasPaste()    if &paste        return '[PASTE]'    else        return ''    endifendfunction"-----------------------------------------------------------" 设置字符集"-----------------------------------------------------------set encoding=utf8set termencoding=utf8set fileencoding=gb19030set fileencodings=utf8,utf16,gb2312,gb18030,ucs-bom,big5,latin1fun! ViewUTF8()    set encoding=utf8    set termencoding=gb19030endfunfun! UTF8()    set encoding=utf8    set termencoding=utf8    set fileencoding=gb18030    set fileencodings=utf8,utf16,gb2312,gb18030,ucs-bom,big5,latin1endfun