" 设置编码
set encoding=utf-8
set langmenu=zh_CN.UTF-8 "set menu's language of gvim. no spaces beside '='
language messages zh_CN.utf-8
" ---------------------- 系统自带设置 -------------------------
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
"------------------- vim基础设置 --------------------------
set nu
set hlsearch
set tabstop=4
set expandtab
set cindent shiftwidth=4
set hidden " 避免当前编辑文档未保存时,在新窗口打开文档
set ignorecase
set cursorline
set textwidth=80
set colorcolumn=+1
set mouse=a
set completeopt=menu " 补全设置
"set statusline=\ %<%F[%1*%M%*%n%R%H]%=\ %y\ %0(%{&fileformat}\ %{&encoding}\ %c:%l/%L%)
set nobackup
set laststatus=2
set nowrap " 不拆行
set fdm=syntax " 代码折叠方式
set nofoldenable " 启动时关闭折叠
"set syntax enable
if has("gui_running") "如果在 GUI 环境下运行则设置下面语句
set guifont=Consolas:h11
set guioptions-=T " 不显示工具栏
set guioptions-=L " 不显示左边滚动条
set guioptions-=r " 不显示右边滚动条
set guioptions-=m
set vb t_vb= " 禁用响铃提醒
au GuiEnter * set t_vb=
"hi SpecialKey guifg=BG
endif
if has("win32")
au GuiEnter * simalt ~x
endif
" --------------------------设置 常用快捷键--------------------------------
nmap Q :NERDTreeClose<CR>:TagbarClose<CR>:bwipe<CR>
nmap <leader>q :q<CR>
nmap <leader>b :ls<CR>
nmap <leader>n :nohl<CR>
nmap <leader>w :update<CR>
nmap <leader>e :browse confirm e<CR>
nmap <leader>s :e $VIM/_vimrc<CR>
nmap <S-Tab> <ESC>:bn<CR>
vmap <S-Tab> <ESC>:bn<CR>
imap <S-Tab> <ESC>:bn<CR>
nmap <C-Tab> <ESC>:b#<CR>
vmap <C-Tab> <ESC>:b#<CR>
imap <C-Tab> <ESC>:b#<CR>
nnoremap <F2> <ESC>:NERDTreeToggle<cr>
vnoremap <F2> <ESC>:NERDTreeToggle<cr>
inoremap <F2> <ESC>:NERDTreeToggle<cr>
nnoremap <F1> <ESC>:TagbarToggle<cr>
vnoremap <F1> <ESC>:TagbarToggle<cr>
inoremap <F1> <ESC>:TagbarToggle<cr>
vmap <F3> <C-C><ESC>/<C-R>+<CR><ESC>
nmap <F3> <ESC>/<C-R>=expand("<cword>")<CR><CR>
imap <F3> <ESC>/<C-R>=expand("<cword>")<CR><CR>
nmap <F4> <ESC>:CtrlPFunky<cr>
vmap <F4> <ESC>:CtrlPFunky<cr>
imap <F4> <ESC>:CtrlPFunky<cr>
" cpp和h文件的切换
nmap <F5> <ESC>:A<CR>
vmap <F5> <ESC>:A<CR>
imap <F5> <ESC>:A<CR>
nnoremap <silent> <F7> <ESC>:<C-R>=line("'<")<CR>,<C-R>=line("'>")<CR>s/^/\/\/<CR>/^$x<CR>
vnoremap <silent> <F7> <ESC>:<C-R>=line("'<")<CR>,<C-R>=line("'>")<CR>s/^/\/\/<CR>/^$x<CR>
inoremap <silent> <F7> <ESC>:<C-R>=line("'<")<CR>,<C-R>=line("'>")<CR>s/^/\/\/<CR>/^$x<CR>
nnoremap <silent> <F8> <ESC>:<C-R>=line("'<")<CR>,<C-R>=line("'>")<CR>s/\/\//<CR>/^$x<CR>
vnoremap <silent> <F8> <ESC>:<C-R>=line("'<")<CR>,<C-R>=line("'>")<CR>s/\/\//<CR>/^$x<CR>
inoremap <silent> <F8> <ESC>:<C-R>=line("'<")<CR>,<C-R>=line("'>")<CR>s/\/\//<CR>/^$x<CR>
nmap <F9> <ESC>:copen<CR><C-W>J
vmap <F9> <ESC>:copen<CR><C-W>J
imap <F9> <ESC>:copen<CR><C-W>J
nmap <F10> <ESC>:ccl<CR>
vmap <F10> <ESC>:ccl<CR>
imap <F10> <ESC>:ccl<CR>
nnoremap <F11> <ESC>:CtrlP<CR>
vnoremap <F11> <ESC>:CtrlP<CR>
inoremap <F11> <ESC>:CtrlP<CR>
nmap <F12> <ESC>:CtrlPBuffer<CR>
vmap <F12> <ESC>:CtrlPBuffer<CR>
imap <F12> <ESC>:CtrlPBuffer<CR>
" -----------------------------------设置各插件-------------------------------------
" Bundle
filetype off
" 设置vundle路径
set rtp+=$VIM/vimfiles/bundle/vundle/
call vundle#rc('$VIM/vimfiles/bundle/')
Bundle 'gmarik/vundle'
"Bundle 'altercation/vim-colors-solarized'
Bundle 'molokai'
Bundle 'Lokaltog/vim-powerline'
Bundle 'majutsushi/tagbar'
Bundle 'scrooloose/nerdtree'
Bundle 'ervandew/supertab'
Bundle 'yegappan/grep'
Bundle 'easymotion/vim-easymotion'
Bundle 'kien/ctrlp.vim'
Bundle 'tacahiroy/ctrlp-funky'
Bundle 'drmingdrmer/xptemplate'
"Bundle 'Valloric/YouCompleteMe'
"Bundle 'vim-scripts/javacomplete'
"Bundle 'vim-scripts/OmniCppComplete'
filetype plugin indent on
" grep
let Grep_Find_Path = '"C:\Program Files\Git\usr\bin\find.exe"'
let Grep_Path = '"C:\Program Files\Git\usr\bin\grep.exe"'
let Grep_Xargs_Path = '"C:\Program Files\Git\usr\bin\xargs.exe"'
let Grep_Default_Options = '-i -r --include="*.cpp" --include="*.h" --include="*.hpp" --include="*.c" --include="*.cc" --include="*.java"'
let Grep_Default_Filelist = '.'
" 设置supertab
let g:SuperTabDefaultCompletionType="context"
let g:SuperTabMappingForward = '<s-tab>'
let g:SuperTabMappingBackward = '<tab>'
" 设置easymotion
let g:EasyMotion_leader_key = ';'
" 设置Tagbar
let g:tagbar_left=1
let g:tagbar_width=30
" 设置 cscope
if has("cscope")
set csprg=cscope
set csto=0
set cst
set cscopequickfix=s-,g-,c-,f-,d-,i-,t-,e-
set nocsverb
set csverb
nmap zs :cs find s <C-R>=expand("<cword>")<CR><CR>
map <C-g><C-g> :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-G><C-C> :cs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-G><C-T> :cs find t <C-R>=expand("<cword>")<CR><CR>
vmap <C-G><C-T> <ESC>:cs find t <C-R>=expand("<cword>")<CR><CR>
imap <C-G><C-T> <ESC>:cs find t <C-R>=expand("<cword>")<CR><CR>
nmap ze :cs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-G><C-f> :cs find f <C-R>=expand("<cword>")<CR><CR>
nmap zi :cs find i ^<C-R>=expand("<cword>")<CR>$<CR>
nmap zd :cs find d <C-R>=expand("<cword>")<CR><CR>
endif
" 设置 ctrlp
let g:ctrlp_map = '' " 去掉ctrl+p快捷键
let g:ctrlp_by_filename = 1
let g:ctrlp_max_height = 25
let g:ctrlp_use_caching = 1
let g:ctrlp_clear_cache_on_exit = 0
let g:ctrlp_cache_dir = $VIM.'/cache/ctrlp'
" 手动指定搜索的根目录let g:ctrlp_root_markers = ['']
"colorscheme solarized
"colorscheme desert
let g:molokai_original=1
colorscheme molokai
"let g:Powerline_colorscheme='solarized256'
let g:Powerline_colorscheme='default'
let g:Powerline_stl_path_style = 'full'
let NERDTreeWinPos='right'
let g:ctrlp_extensions = ['funky']
let g:ctrlp_funky_syntax_highlight = 1