=============================================================================================
""""""""""""""""""""""""""""""""""""""""""""
" basic setting
"""""""""""""""""""""""""""""""""""""""""""
set number
set ruler
set backspace=indent,eol,start
set showmatch
set hlsearch
set incsearch
""" 去掉vi一致性
set nocompatible
""" 设置ambiwidth
" set ambiwidth=double
" set confirm
set showcmd
" set laststatus=2
" set history=700
" set cursorline
" set autochdir
" set ignorecase
""" Tab键的宽度
set tabstop=4
""" 统一缩进为4
set softtabstop=4
set shiftwidth=4
""" 用空格代替制表符
" set expandtab
""" 自动缩进
set autoindent
" set smartindent
" set cindent
""" 语法高亮
syntax enable
syntax on
""" 颜色模式
" colorscheme anotherdark
""" 填充匹配的右括号
" inoremap ( ()
" inoremap { {}
" inoremap [ []
""" 设置编码
set encoding=utf-8
set termencoding=gb2312
set fileencodings=ucs-bom,utf-8,gb18030,utf-16,big5,chinese
""" 鼠标设置
" set mouse=a
" set mousemodel=popup
" set selection=exclusive
" set selectmode=mouse,key
" behave mswin
""" 代码折叠
" set foldenable
" foldmethod : indent, manual, syntax, expr, diff, marker
" set foldmethod=indent
" set foldopen=all
" set foldclose=all
" set foldcolumn=4
" setlocal foldlevel=100
""" fold cmd : zf zo zc zd zr zm zR zM zn zi zN
" nnoremap @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')
""" 侦测文件类型
filetype on
""" 载入文件类型插件
filetype plugin indent on
""" 关掉智能补全时的预览窗口
" set completeopt=longest,menu
""" 设置的leader
let mapleader=","
"""""""""""""""""""""""""""""
" basic快捷操作
"""""""""""""""""""""""""""""
nmap ( 5<
nmap ) 5>
nmap - 5-
nmap = 5+
map
nnoremap :Grep
"""""""""""""""""""""""""
" basic代码补全
"""""""""""""""""""""""""
""" CTRL-N和CTRL-P能对局部变量进行补全
""" CTRL-P一般的含义是向上;CTRL-N是向下查找以进行补全
" inoremap "根据标签补全
" inoremap "补全文件名
" inoremap "补全宏定义
" inoremap "整行补全
""""""""""""""""""""""""""""""
" netrw setting
""""""""""""""""""""""""""""""
" nmap fe :***plore!
" let g:netrw_winsize = 30
""""""""""""""""""""""""""""""
" MiniBufExplorer
""""""""""""""""""""""""""""""
" nmap mb :MiniBufExplorer
" let g:miniBufExplMapWindowNavVim = 1 "按下Ctrl+h/j/k/l,可以切换到当前窗口的上下左右窗口
" let g:miniBufExplMapWindowNavArrows = 1 "按下Ctrl+箭头,可以切换到当前窗口的上下左右窗口
" let g:miniBufExplMapCTabSwitchBufs =1
" let g:miniBufExplModSelTarget =1
""""""""""""""""""""""""""""""
" BufExplorer
""""""""""""""""""""""""""""""
" nmap bf :BufExplorer
let g:bufExplorerDefaultHelp=0 " Do not show default help.
let g:bufExplorerShowRelativePath=1 " Show relative paths.
let g:bufExplorerSortBy='mru' " Sort by most recently used.
let g:bufExplorerSplitRight=0 " Split left.
let g:bufExplorerSplitVertical=1 " Split vertically.
let g:bufExplorerSplitVertSize = 30 " Split width
" let g:bufExplorerUseCurrentWindow=1 " Open in new window.
" autocmd BufWinEnter \[Buf\ List\] setl nonumber
"""""""""""""""""""""""""
" winManager
"""""""""""""""""""""""""
nmap wm :WMToggle
nmap fir :FirstExplorerWindow
nmap bot :BottomExplorerWindow
""" option : BufExplorer, FileExplorer, TagList
let g:winManagerWindowLayout = "BufExplorer|FileExplorer"
" let g:persistentBehaviour=0 " 如果所有编辑文件都关闭了,退出vim
let g:winManagerWidth = 30
let g:defaultExplorer = 1
let g:persistentBehaviour=0 "只剩一个窗口时, 退出vim.
""""""""""""""""""""""""""""
" NERDTree NERD_commenter
""""""""""""""""""""""""""""
map nd :NERDTree
map nc :NERDTreeClose
""" 对NERD_commenter的设置
" [count],cc 光标以下count行逐行添加注释(7,cc)
" [count],cu 光标以下count行逐行取消注释(7,cu)
" [count],cm 光标以下count行尝试添加块注释(7,cm)
" ,ca,在可选的注释方式之间切换,如块注释/* */和行注释//
" ,cA 在行尾插入 ,并且进入插入模式。 这个命令方便写注释。
""" 注:count参数可选,无则默认为选中行或当前行
let NERDShutUp=1 "在光标所在行上,按下一次ctrl+h是注释,再按下一次是取消注释
let NERDSpaceDelims=1 " 让注释符与语句之间留一个空格
let NERDCompact***yComs=1 " 多行注释时样子更好看
"""""""""""""""""""""""""
" ctags
"""""""""""""""""""""""""
""" Ctrl+] 压栈(跳到标记定义处); Ctrl+W ] 在横着的新窗口打开(:stag tagname)
""" n Ctrl+t 出栈(后跳n次,会使你的:tags列出的表缩短); 跨文件时,用 Ctrl+o才能跳回去
""" 定制的tags
" set tags+=/home/xxxxx/.vimhome/vim72/share/vim/vimfiles/tags/cpp_tags
set tags+=/home/xxxxx/.vimhome/vim72/share/vim/vimfiles/tags/glib_tags
set tags+=/home/xxxxx/.vimhome/vim72/share/vim/vimfiles/tags/libc_tags
set tags+=/home/xxxxx/.vimhome/vim72/share/vim/vimfiles/tags/susv2_tags
""" cmd : ctags -R --c++-kinds=+p --fields=+iaS --extra=+q --language-force=C++ cpp_src
""" generate ctags for current folder
""" add current directory's generated tags file to available tags
""" map :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .
" map :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q . :TlistUpdate
" set tags+=./tags
noremap :call Do_ctags()
function Do_ctags()
silent! execute "!ctags -R --c++-kinds=+p --fields=+ialS --extra=+q '.'"
silent! execute "set tags+=./tags"
silent! execute "TlistUpdate"
endf
"""""""""""""""""""""""""
" taglist
"""""""""""""""""""""""""
map tl :TlistToggle
let Tlist_Ctags_Cmd='/home/xxxxx/.vimhome/ctags58/bin/ctags'
let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1
let Tlist_Use_Right_Window=1 " 把taglist窗口放在屏幕的右侧,缺省在左侧
let Tlist_Process_File_Always=1 "实时更新tags
" let Tlist_Show_Menu=1 " 显示taglist菜单
" let Tlist_File_Fold_Auto_Close=1 " 让当前不被编辑的文件的方法列表自动折叠起来
if(v:version >= 700)
set completeopt=longest,menu
endif
"""""""""""""""""""""""""""""""""
" OmniCppComplete
"""""""""""""""""""""""""""""""""
inoremap pumvisible()?"\":"\"
inoremap
pumvisible()?"\\\":"\"inoremap
pumvisible()?"\\\":"\"inoremap pumvisible()?"\":"\"
let OmniCpp_NamespaceSearch = 1
let OmniCpp_GlobalScopeSearch = 1
let OmniCpp_ShowAccess = 1
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 included files
let OmniCpp_ShowPrototypeInAbbr = 1 " show function prototype (i.e. parameters) in popup window
" auto close options when exiting insert mode
" autocmd InsertLeave * if pumvisible() == 0|pclose|endif
" set completeopt=menu,menuone
"""""""""""""""""""""""""""""""""
" cscope
"""""""""""""""""""""""""""""""""
""" cscope -Rbqk "项目根目录运行,为代码生成一个cscope数据库
""" R 表示把所有子目录里的文件也建立索引; b 表示cscope不启动自带的用户界面,而仅仅建立符号数据库
""" q 生成cscope.in.out和cscope.po.out文件,加快cscope的索引速度; k 在生成索引文件时,不搜索/usr/include目录
""" Tab键来进行匹配内容和输入项的切换; ctrl+r,ctrl+d退出 cscope
" cscope -Rbq -f path/xxx.out
" cs add path/xxx.out
" noremap :!find . -name "*.h" -o -name "*.c" -o -name "*.cc" > ./cscope.files
" noremap :!cscope -Rbkq -i cscope.files
" noremap :!cs add cscope.out
if has("cscope")
set csprg=/home/xxxxx/.vimhome/cscope157/bin/cscope
set csto=0
set cscopetag
set nocsverb
"add any database in current directory
if filereadable("cscope.out")
cs add cscope.out
" else add database pointed to by environment
elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
endif
set csverb
set cscopetag
"使用 quickfix 窗口来显示 cscope 结果
set cscopequickfix=s-,g-,c-,d-,t-,e-,f-,i-
endif
" nmap s :cs find s =expand("") "s:查找C语言符号,即查找函数名,宏,枚举值等出现的地方
" nmap g :cs find g =expand("") "g:查找函数,宏,枚举等定义的位置,类似ctags所提供的功能
" nmap c :cs find c =expand("") "c:查找调用本函数的函数
" nmap t :cs find t =expand("") "t:查找指定的字符串
" nmap e :cs find e =expand("") "e:查找egrep模式,相当于egrep功能,但查找速度快多了
" nmap f :cs find f =expand("") "f:查找并打开文件,类似vim的find功能
" nmap i :cs find i ^=expand("")$ "i: 查找包含本文件
" nmap d :cs find d =expand("") "d:查找本函数调用的函数
nmap :cs find s =expand("") :cw
noremap :call Do_CsTag()
function Do_CsTag()
if(executable('cscope') && has("cscope") )
silent! execute "!find . -name '*.h' -o -name '*.c' -o -name '*.cpp' -o -name '*.php' > cscope.files"
silent! execute "!cscope -Rbkq"
if filereadable("cscope.out")
execute "cs add cscope.out"
endif
endif
endf
"""""""""""""""""""""""""""""""""
" 在 h 和 .c/.cpp 文件中切换
"""""""""""""""""""""""""""""""""
nnoremap :A
nnoremap :AS
nnoremap :AV
"""""""""""""""""""""""""
" superTab
"""""""""""""""""""""""""
let g:SuperTabRetainCompletionType=2
let g:SuperTabDefaultCompletionType=""
"""""""""""""""""""""""""
" snipMate
"""""""""""""""""""""""""
""" 将snipMate的快捷键转到ctrl+j, 因为默认的快捷键tab会和pydiction冲突
" ino =TriggerSnippet()
" snor i=TriggerSnippet()
"""""""""""""""""""""""""
" QuickFix
"""""""""""""""""""""""""
""" cn 切换到下一个结果; cp 切换到上一个结果
""" cc 显示详细错误信息; cl 列出所有错误
""" cw 如果有错误列表,则打开quickfix窗口
""" col cnew 到前一个旧(后一个较新)的错误列表
""" (先按,再按空格)就可以编译,使用”cp“和”cn“跳到上一个和下一个错误"cw"来打开一个quickfix窗口
" autocmd FileType c,cpp map :w:make
" nmap cn :cn
" nmap cp :cp
" nmap cw :cw 10
nmap q :q
"""""""""""""""""""""""""
" echofunc
"""""""""""""""""""""""""
""" 按键"Alt+-"和"Alt+="向前和向后翻页
let g:EchoFuncKeyNext=''
let g:EchoFuncKeyPrev=''
if(v:version >= 700)
set laststatus=2
if has('statusline')
let g:EchoFuncShowOnStatus=1
set statusline=%<%f\ %{EchoFuncGetStatusLine()}\ %h%m%r%=%-10.(%l,%c%V%)\ %P(%L)\
endif
endif
"""""""""""""""""""""""""""""""""
" php 全能提示触发命令
"""""""""""""""""""""""""""""""""
" if !exists('g:AutoComplPop_Behavior')
" let g:AutoComplPop_Behavior = {}
" let g:AutoComplPop_Behavior['php'] = []
" call add(g:AutoComplPop_Behavior['php'], {
" \ 'command' : "\\",
" \ 'pattern' : printf('\(->\|::\|\$\)\k\{%d,}$', 0),
" \ 'repeat' : 0,
" \})
" endif
"""""""""""""""""""""""""""""""""
" assistant 支持PHP、JS、Vim脚本
"""""""""""""""""""""""""""""""""
""" 显示当前位置函数或者变量名等关键字的原型
""" 补全当前位置关键字
"""""""""""""""""""""""""""""""""""
" c cpp IDE
"""""""""""""""""""""""""""""""""""
if(v:version >= 700)
set runtimepath+=/home/xxxxx/.vimhome/vim72/share/vim/cvim_IDE
set runtimepath+=/home/xxxxx/.vimhome/vim72/share/vim/cvim_IDE/after
endif
"""""""""""""""""""""""""""""""""""
" bash IDE
"""""""""""""""""""""""""""""""""""
" if(v:version >= 700)
" set runtimepath+=/home/xxxxx/.vimhome/vim72/share/vim/bash_IDE
" set runtimepath+=/home/xxxxx/.vimhome/vim72/share/vim/bash_IDE/after
" endif
"""""""""""""""""""""""""""""""""
" python IDE
"""""""""""""""""""""""""""""""""
""" Python代码检查(pyflakes)
""" 执行命令:cc,即可进行代码检查
""" VimPdb 调试Python程序
""" F5运行,F2设置断点,在运行到断点后可以用按F12可以查看
""" F7/F8 - Step into/over,F12 - Print stack trace
""" F3/Ctrl-F3 - Eval/Exec a given statement (in the current debugging context)
if(v:version >= 700)
let $PYTHONHOME="/home/xxxxx/.vimhome/python273"
" set runtimepath+=/home/xxxxx/.vimhome/vim72/share/vim/python_IDE
" set runtimepath+=/home/xxxxx/.vimhome/vim72/share/vim/python_IDE/after
" autocmd FileType python set omnifunc=pythoncomplete#Complete
let g:pydiction_location = '/home/xxxxx/.vimhome/vim72/share/vim/python_IDE/pydiction/complete-dict'
let g:pydiction_menu_height = 20
endif
autocmd FileType python set expandtab
"""""""""""""""""""""""""""""""""
" 记录文件上次编辑的位置
"""""""""""""""""""""""""""""""""
if(v:version >= 700)
autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
" autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g'\"" | endif