定制.vimrc配置文件

文件下载点,如有如需要请点击(不需要积分)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=1
else
    let g:isWin=0
endif

"----------------------------------------------------------
" 常用格式
"----------------------------------------------------------
" 习惯用“:”作为命令前缀
"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 expandtab
set smarttab
set shiftwidth=4
set tabstop=4
" 恢复上次文件打开位置
"set viminfo='10,\"100,:20,%,n~/.viminfo
if has("autocmd")
    autocmd BufReadPost * 
        \ if line("'\"") > 0 | if line("'\"") <= line("{1}quot;) |
        \ exe("norm '\"") | else|exe "norm {1}quot;|
        \ endif | endif
endif

" 关闭兼容模式
set nocompatible
" 语法高亮
syntax enable
" 文件类型插件
filetype plugin on
filetype indent on
set autoindent
autocmd 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=2
set ruler
set 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%%/%L
function! CurDir()
    let curdir = substitute(getcwd(), $HOME, "~", "")
    return curdir
endfunction

function! HasPaste()
    if &paste
        return '[PASTE]'
    else
        return ''
    endif
endfunction

"-----------------------------------------------------------
" 设置字符集
"-----------------------------------------------------------
set encoding=utf8
set termencoding=utf8
set fileencoding=gb19030
set fileencodings=utf8,utf16,gb2312,gb18030,ucs-bom,big5,latin1

fun! ViewUTF8()
    set encoding=utf8
    set termencoding=gb19030
endfun

fun! UTF8()
    set encoding=utf8
    set termencoding=utf8
    set fileencoding=gb18030
    set fileencodings=utf8,utf16,gb2312,gb18030,ucs-bom,big5,latin1
endfun
    

posted on 2011-12-10 01:41  YoungerChina  阅读(287)  评论(0编辑  收藏  举报

导航