具体步骤首先输入:
代码: 全选
ctags -I __THROW --file-scope=yes --langmap=c:+.h --languages=c,c++ --links=yes --c-kinds=+p --extra=+q -R -f ~/.vim/systags /usr/include /usr/local/include
在vimrc中加入:
代码: 全选
set tags+= ~/.vim/systags
代码: 全选
" All system-wide defaults are set in $VIMRUNTIME/debian.vim (usually just
" /usr/share/vim/vimcurrent/debian.vim) and sourced by the call to :runtime
" you can find below. If you wish to change any of those settings, you should
" do it in this file (/etc/vim/vimrc), since debian.vim will be overwritten
" everytime an upgrade of the vim packages is performed. It is recommended to
" make changes after sourcing debian.vim since it alters the value of the
" 'compatible' option.
" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
runtime! debian.vim
" Uncomment the next line to make Vim more Vi-compatible
" NOTE: debian.vim sets 'nocompatible'. Setting 'compatible' changes numerous
" options, so any other options should be set AFTER setting 'compatible'.
"set compatible
" Vim5 and later versions support syntax highlighting. Uncommenting the
" following enables syntax highlighting by default.
if has("syntax")
syntax on
endif
" If using a dark background within the editing area and syntax highlighting
" turn on this option as well
"set background=dark
" Uncomment the following to have Vim jump to the last position when
" reopening a file
"if has("autocmd")
" au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
"endif
" Uncomment the following to have Vim load indentation rules and plugins
" according to the detected filetype.
"if has("autocmd")
" filetype plugin indent on
"endif
" The following are commented out as they cause vim to behave a lot
" differently from regular Vi. They are highly recommended though.
"set showcmd " Show (partial) command in status line.
"set showmatch " Show matching brackets.
"set ignorecase " Do case insensitive matching
set smartcase " Do smart case matching
"高亮显示结果
set hlsearch
set incsearch " Incremental search
"set autowrite " Automatically save before commands like :next and :make
"set hidden " Hide buffers when they are abandoned
set mouse=a " Enable mouse usage (all modes)
" Source a global configuration file if available
if filereadable("/etc/vim/vimrc.local")
source /etc/vim/vimrc.local
endif
"关闭vi兼容
set nocp
"语法高亮
syntax enable
syntax on
filetype plugin indent on
"taglist
let Tlist_Ctags_Cmd='/usr/local/bin/ctags'
let Tlist_Show__One_File=1
let Tlist_Exit_OnlyWindow=1
let Tlist_Auto_Open=0
let Tlist_Auto_Update=1
"色彩
colorscheme default
"minibuff
let g:miniBufExplMapWindowNavVim=1
let g:miniBufExplMapWindowNavArrows=1
let g:miniBufExplMapCtapSwitchBufs=1
let g:miniBufExplModSelTarget=1
"a.vim配置
nnoremap <silent><F12> :A<CR>
"grep
nnoremap <silent><F5> :Grep<CR>
"supertap
let g:SuperTabRetainCompletionType=2
let g:SuperTabDefaultCompletionType="<C-X><C-O>"
"智能补全
set completeopt=longest,menu
"map <C-F12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR>
map <C-F12> :!ctags -R --extra=+f --languages=c --langmap=c:+.h --c-kinds=+px --fields=+aiKSz
"设置行号
set nu
"设置trinity
nmap <F8> :TrinityToggleAll<CR>
nmap <F9> :TrinityToggleSourceExplorer<CR>
nmap <F3> :TrinityToggleTagList<CR>
nmap <F4> :TrinityToggleNERDTree<CR>
"设置srcexpl
let g:SrcExpl_winHeight=8
let g:SrcExpl_refreshTime=100
let g:SrcExpl_jumpKey="<ENTER>"
let g:SrcExpl_gobackKey="<SPACE>"
let g:SrcExpl_pluginList=[
\"__Tag_List__",
\"_NERD_tree_",
\"Source_Explorer"
\]
let g:SrcExpl_searchLoalDef=1
let g:SrcExpl_isUpdateTags=0
let g:SrcExpl_updateTagsCmd="ctags --sort=foldcase -R."
let g:SrcExpl_updateTagsKey="<F12>"
"
:imap <F2> <Esc>:w<CR>
:nmap ` :q!<CR>
:imap { {<CR>}<Esc>kA<CR>
"设置显示中文字体
let &termencoding=&encoding
set fileencodings=utf-8,gbk,ucs-bom,cp936
"NERD_commenter设置
let NERDShutUp=1
""支持单行和多行的选择,//格式
map <c-h> ,c<space>
:inoremap [ []<ESC>i
"mapping
inoremap <expr> <Space> pumvisible()?"\<C-Y>":"\<Space>"
inoremap <expr> <C-J> pumvisible()?"\<PageDown>\<C-N>\<C-P>":"\<C-X><C-O>"
inoremap <expr> <C-K> pumvisible()?"\<PageUp>\<C-P>\<C-N>":"\<C-K>"
inoremap <expr> <C-U> pumvisible()?"\<C-E>":"\<C-U>"
inoremap <expr> j pumvisible()?"\<Down>":"\j"
inoremap <expr> k pumvisible()?"\<Up>":"\k"
"不生成备份文件
set nobackup
set nowritebackup
"
set ofu=syntaxcomplete
"补全
inoremap <F3> <C-X><C-N>
inoremap <F4> <C-X><C-P>
"自动缩进
set autoindent
set showmatch
set smartindent
set ai!
"高亮显示txt文档
let tlist_txt_settings = 'txt;c:content;f:figures;t:tables'
au BufRead,BufNewFile *.txt setlocal ft=txt
set cindent
"设置ctags.vim
let g:ctags_path='/usr/local/bin/ctags'
let g:ctags_statusline=1
" build tags of your own project with Ctrl-F12
" map <C-F12> :!ctags -R --sort=yes --c++-kinds=+p --fields=+iaS --extra=+q
" .<CR>
"
" " OmniCppComplete
let OmniCpp_NamespaceSearch = 1
let OmniCpp_GlobalScopeSearch = 1
let OmniCpp_ShowAccess = 1
let OmniCpp_ShowPrototypeInAbbr = 1 " show function parameters
let OmniCpp_MayCompleteDot = 1 " autocomplete after .
let OmniCpp_MayCompleteArrow = 1 " autocomplete after ->
let OmniCpp_MayCompleteScope = 1 " autocomplete after ::
let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]
" automatically open and close the popup menu / preview window
au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
set completeopt=menuone,menu,longest,preview
map <F7> <Plug>ShowFunc
map! <F7> <Plug>ShowFunc
"cscope
:set cscopequickfix=s-,c-,d-,i-,t-,e-
nmap <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>
"自动运行gcc,g++
" C的编译和运行
map <F6> :call CompileRunGcc()<CR>
func! CompileRunGcc()
exec "w"
exec "!gcc % -o %<"
exec "! ./%<"
endfunc
" C++的编译和运行
map <F5> :call CompileRunGpp()<CR>
func! CompileRunGpp()
exec "w"
exec "!g++ % -o %<"
exec "! ./%<"
endfunc
" 显示状态栏 (默认值为 1, 无法显示状态栏)
set laststatus=2
" 状态行颜色
highlight StatusLine guifg=SlateBlue guibg=Yellow
highlight StatusLineNC guifg=Gray guibg=White
function! CurDir()
let curdir = substitute(getcwd(), '/Users/amir/', "~/", "g")
return curdir
endfunction
"自动生成tags标志
au BufWrite *.cpp,*.h,*.c,*.rl,*.def call system("ctags -a -f ~/.vim/tags/local/ctags --extra=+q " . expand("%:p"))
au BufWrite *.rb call system("ctags -a -f ~/.vim/tags/local/rbtags --extra=+q " . expand("%:p"))
au BufWrite *.py call system("ctags -a -f ~/.vim/tags/local/pytags --extra=+q " . expand("%:p"))
au BufWrite *.java call system("ctags -a -f ~/.vim/tags/local/javatags --extra=+q " . expand("%:p"))
au BufRead,BufNewFile *.rb setlocal tags+=~/.vim/tags/local/rbtags,~/.vim/tags/linux/rbtags
au BufRead,BufNewFile *.cpp,*.h,*.c setlocal tags+=~/.vim/tags/local/ctags,~/.vim/tags/linux/ctags,~/.vim/systags
au BufRead,BufNewFile *.rl,*.def setlocal tags+=~/.vim/tags/local/ctags,~/.vim/tags/linux/ctags
au BufRead,BufNewFile *.py setlocal tags+=~/.vim/tags/local/pytags,~/.vim/tags/linux/pytags
au BufRead,BufNewFile *.java setlocal tags+=~/.vim/tags/local/javatags,~/.vim/tags/linux/javatags
set tags=./.tags;${HOME}