set nocompatible               " be iMproved

filetype on                   " required!
 
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
 
" let Vundle manage Vundle
" required!
Bundle 'gmarik/vundle'
 
"" My Bundles here:
""
"" original repos on github
"Bundle 'tpope/vim-fugitive'
"Bundle 'Lokaltog/vim-easymotion'
"Bundle 'rstacruz/sparkup', {'rtp': 'vim/'}
"Bundle 'tpope/vim-rails.git'
"" vim-scripts repos
"Bundle 'L9'
"Bundle 'FuzzyFinder'
"" non github repos
"Bundle 'git://git.wincent.com/command-t.git'
"" ...
 
filetype plugin indent on     " required!
"
" Brief help  -- 此处后面都是vundle的使用命令
" :BundleList          - list configured bundles
" :BundleInstall(!)    - install(update) bundles
" :BundleSearch(!) foo - search(or refresh cache first) for foo
" :BundleClean(!)      - confirm(or auto-approve) removal of unused bundles
"
" see :h vundle for more details or wiki for FAQ
" NOTE: comments after Bundle command are not allowed..


"Bundle 'https://github.com/Lokaltog/vim-powerline.git'
Bundle 'The-NERD-tree'
Bundle 'winmanager'
Bundle 'taglist.vim'
Bundle 'a.vim'
Bundle 'grep.vim'
Bundle 'vmark.vim--Visual-Bookmarking'
Bundle 'word_complete.vim'
"hight ligtht class and function-member in cpp
"Bundle 'cpp.vim'
"Bundle 'highlight.vim'
"Bundle 'highlight_cursor.vim'
"Bundle 'mark.vim'
Bundle 'c.vim'
"Bundle 'minibufexpl.vim'
Bundle 'bufexplorer.zip'
"Bundle 'OmniCppComplete'
Bundle 'DoxygenToolkit.vim'
Bundle 'vim-easy-align.vim'

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
""DoxygenToolkit插件
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
let g:DoxygenToolkit_authorName="@author yingc"


"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
""vim-powerline插件
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
"set laststatus=2
"set t_Co=256
"let g:Powerline_symbols = 'unicode'
"set encoding=utf8




"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
" MiniBufExplorer插件
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
"let g:miniBufExplMapCTabSwitchBufs = 1
""可以用<C-h,j,k,l>切换到上下左右的窗口中去,就像:C-w,h j k l    向左,下,上,右切换窗口.
"let g:miniBufExplMapWindowNavVim = 1
"用<C-箭头键>切换到上下左右窗口中去
"let g:miniBufExplMapWindowNavArrows = 1


"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
" WinManager插件
" 用法:  :e .    ==>can open current dir
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
"将TagList窗口和netrw窗口整合起来
"let g:winManagerWindowLayout='FileExplorer|TagList'
"nmap wm :WMToggle<cr>



"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
"cscope快捷键设置"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
if has("cscope")
    set csto=0
    set nocsverb
    " add any database in current directory
    if filereadable("cscope.out")
        cs add cscope.out
    endif
    set csverb
    "set cst  这两句会将cscope当作tag，当找不到时会卡住，因此注释掉
    "set cscopetag
endif
:set csprg=/usr/bin/cscope

"nmap <F1> :cs find c <C-R>=expand("<cword>")<CR><CR>
"nmap <F5> :cs find g <C-R>=expand("<cword>")<CR><CR>
"nmap <F1> :cs find t <C-R>=expand("<cword>")<CR><CR>
":cw


nnoremap  <C-h> :cs find g <C-R>=expand("<cword>")<CR><CR>
nnoremap  <C-y> :cs find t <C-R>=expand("<cword>")<CR><CR>

"nnoremap <C-_>s :cs find s <C-R>=expand("<cword>")<CR><CR>
"nmap <C-_>g :cs find g <C-R>=expand("<cword>")<CR><CR>
"nmap <C-_>c :cs find c <C-R>=expand("<cword>")<CR><CR>
"nmap <C-_>t :cs find t <C-R>=expand("<cword>")<CR><CR>
"nmap <C-_>e :cs find e <C-R>=expand("<cword>")<CR><CR>
"nmap <C-_>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
"nmap <C-_>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
"nmap <C-_>d :cs find d <C-R>=expand("<cword>")<CR><CR>

:set cscopequickfix=s-,c-,d-,i-,t-,e-

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
"cw快捷键设置"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
"切换到上一个结果
nmap <F6> :cn<cr>
"切换到下一各结果
nmap <F7> :cp<cr>     


"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
"	c/h文件间相互切换快捷键设置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
"nnoremap <silent> <F12> :A<CR>





"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
" grep.vim 在vim中进行查找的快捷键
" 注：这个插件使用的有问题
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
"nnoremap <silent> <F5> :Grep<CR>




"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
"	vmark.vim--Visual-Bookmarking
"	don't need any config
"	mm:set the mark
"	F2:this can change beween marks
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 



"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
"	word_complete.vim设置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
"let g:WC_min_len=3 "当输入到第3个字母时才自动补全，自己可以改变.
":autocmd BufEnter * call DoWordComplete() "每个buffer自动启用自动补全.




"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
"	The-NERD-tree设置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
nmap <F4> :NERDTree<cr>



""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
" taglist插件
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
" 按照名称排序 
let Tlist_Sort_Type = "name"
" 在右侧显示窗口 
let Tlist_Use_Right_Window = 1
" 压缩方式 
let Tlist_Compart_Format = 1
" 如果只有一个buffer，kill窗口也kill掉buffer 
let Tlist_Exist_OnlyWindow = 1
" 不要关闭其他文件的tags 
let Tlist_File_Fold_Auto_Close = 0
" 不要显示折叠树 
let Tlist_Enable_Fold_Column = 0
let Tlist_Show_Menu = 1
let Tlist_Show_One_File = 1

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
"omnicppcomplete设置
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
"""按下F3自动补全代码，注意该映射语句后不能有其他字符，包括tab；否则按下F3会自动补全一些乱码
"imap <F3> <C-X><C-O>
"" 按下F2根据头文件内关键字补全
" imap <F2> <C-X><C-I>
 set completeopt=menu,menuone " 关掉智能补全时的预览窗口
 let OmniCpp_MayCompleteDot = 1 " autocomplete with .
 let OmniCpp_MayCompleteArrow = 1 " autocomplete with ->
 let OmniCpp_MayCompleteScope = 1 " autocomplete with ::
 let OmniCpp_SelectFirstItem = 2 " select first item (but don't insert)
 let OmniCpp_NamespaceSearch = 2 " search namespaces in this and includedfiles
 let OmniCpp_ShowPrototypeInAbbr = 1 " show function prototype in popupwindow
 let OmniCpp_GlobalScopeSearch=1 " enable the global scope search
 let OmniCpp_DisplayMode=1 " Class scope completion mode: always show allmembers
 let OmniCpp_DefaultNamespaces=["std"]
 let OmniCpp_ShowScopeInAbbr=1 " show scope in abbreviation and remove the
 "last column
 let OmniCpp_ShowAccess=1

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
" vim-easy-align.vim设置
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
"vmap <Leader>a <Plug>(EasyAlign)
"nmap <Leader>a <Plug>(EasyAlign)
"if !exists('g:easy_align_delimiters')
"	let g:easy_align_delimiters = {}
"endif
"let g:easy_align_delimiters['#'] = { 'pattern': '#', 'ignore_groups': ['String'] }
"
" Start interactive EasyAlign in visual mode (e.g. vipga)
xmap ga <Plug>(EasyAlign)

" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)


""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
" vim通用设置
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 
" 设定默认解码 
" set fenc=utf-8 
" set fencs=utf-8,usc-bom,euc-jp,gb18030,gbk,gb2312,cp936 

"set fencs=utf-8,cp936               "设定默认解码
"set fileencodings=utf-8,gb2312,gbk,gb18030  "从磁盘读取文件的时候，通过此设置完成自动识别编码
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
set termencoding=utf-8              "用于屏幕显示的编码方式
set encoding=utf-8              "vim内部使用的字符编码方式 --通常为utf-8 修改为prc是为解决中文乱码

" 不要使用vi的键盘模式，而是vim自己的 
set nocompatible 

" history文件中需要记录的行数 
set history=100 

" 在处理未保存或只读文件的时候，弹出确认 
set confirm 

" 与windows共享剪贴板 
set clipboard+=unnamed 

" 侦测文件类型 
filetype on 

" 载入文件类型插件 
filetype plugin on 

" 为特定文件类型载入相关缩进文件 
filetype indent on 

" 保存全局变量 
set viminfo+=! 

" 带有如下符号的单词不要被换行分割 
set iskeyword+=_,$,@,%,#,- 

" 语法高亮 
syntax on 

" 高亮字符，让其不受100列限制 
:highlight OverLength ctermbg=red ctermfg=white guibg=red guifg=white 
:match OverLength '\%101v.*' 

" 状态行颜色 
highlight StatusLine guifg=SlateBlue guibg=Yellow 
highlight StatusLineNC guifg=Gray guibg=White 



:set nocompatible      " 不使用vi默认键盘布局"
:set number             "  显示行号"
:set autoindent         " 自动对齐"
:set smartindent        " 智能对齐"
:set showmatch         " 括号匹配模式"
":set ruler                　"显示状态行"
" 在状态行上显示光标所在位置的行号和列号 
set ruler 
set rulerformat=%20(%2*%<%f%=\ %m%r\ %3l\ %c\ %p%%%) 
" 我的状态行显示的内容（包括文件类型和解码） 
set statusline=%F%m%r%h%w\[POS=%l,%v][%p%%]\%{strftime(\"%d/%m/%y\ -\%H:%M\")} 

" 总是显示状态行 
set laststatus=2 
:set incsearch           "查询时非常方便，如要查找book单词，当输入到/b时，会自动找到第一个b开头的单词，当"
:set tabstop=4          " tab键为4个空格"
:set shiftwidth=4    "　换行时行间交错使用4个空格"
"":set softtabstop=4"　" 设置（软）制表符宽度为4"
:set cindent             " C语言格式对齐"
:set nobackup           " 不要备份文件"
:set clipboard+=unnamed  " 与windows共享剪贴板"

"显示tab键为▸
set list
set listchars=tab:▸\ ,

syntax enable
syntax on
colorscheme desert


set hls
set cursorline 
"syntax off  "securecrt中语法有下划线，需要将此关掉
" 在搜索的时候忽略大小写 
set ignorecase 


"============================================================================================
" 以下是强制配置，不得修改，须放在 .vimrc 的最后面
"============================================================================================
"set fencs=utf-8,cp936

" 删除行尾空格
nnoremap <leader>f :%s/\s\+$//<cr>

function! KRIndent()
    let c_space_errors = 0
    set fileformats=unix
    set textwidth=120
    set noexpandtab
    set shiftround
    set cindent
    set formatoptions=tcqlron
    set cinoptions=:0,l1,t0,g0
    syntax keyword cType u8 u16 u32 u64 s8 s16 s32 s64 off64_t
    highlight default link LinuxError ErrorMsg

    syntax match LinuxError / \+\ze\t/     " spaces before tab
    syntax match LinuxError /\s\+$/        " trailing whitespaces
    syntax match LinuxError /\%121v.\+/    " virtual column 121 and more
endfunction
if has("autocmd")
    autocmd FileType c,cpp,h,hh call KRIndent()
endif

map <leader><leader> :BufExplorer<Enter>
"
"set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
set fileencodings=utf-8,cp936,latin1
set termencoding=utf-8              "用于屏幕显示的编码方式
set encoding=utf-8              "vim内部使用的字符编码方式 --通常为utf-8 修改为prc是为解决中文乱码
":cs add /workteam/yinguicai/data/work/svn/index/e/cscope.out /workteam/yinguicai/data/work/svn/index/e
":set tags=/workteam/yinguicai/data/work/svn/index/e/tags

let g:C_Styles = { '*.c,*.h' : 'default', '*.cc,*.cpp,*.hh,*.hpp' : 'CPP' }
"set completeopt=menuone,longest





