檢查是否安裝了vim,ctags,cscope,如果沒有請安裝。
我的配置文件--vimrc.(來自網絡了,作者找不到了。。。抱歉啦)
- set tags=./tags;
- set helplang=cn
- set autochdir
- set cindent
- set cinoptions={0,1s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1s
- set expandtab
- set fileencodings=ucs-bom,utf8,GB18030,Big5,latin1
- set fileformat=unix
- set cursorline
- set history=50
- set hlsearch
- set ignorecase
- set incsearch
- set laststatus=2
- set nobackup
- set nocompatible
- set number
- "set paste
- set ruler
- set shiftwidth=4
- set showcmd
- set showmatch
- set smartcase
- set smartindent
- set softtabstop=4
- set statusline=%F%m%r,\ %Y,\ %{&fileformat}\ \ \ ASCII=\%b,HEX=\0x\%B\ \ \ %l,%c%V\ \ %p%%
- set tabstop=4
- colorscheme desert
- "set nocscopeverbose
- syntax enable
- syntax on
- filetype plugin indent on
- set completeopt=longest,menu
- "hi Cursorline ctermbg=Blue guibg=#3CF60B
- ":map <C-F9> :!g++ % -o %<<CR>
- :map <F9> :!g++ -Wall -ggdb % -o %<<CR>
- :map <F10> :!./%<<CR>
- :map <C-c> :!clear<CR>
- :map <F6> :tabprevious<CR>
- :map <F7> :tabnew<CR>
- :map <F8> :tabnext<CR>
- :map <F2> :w<CR>
- "runtime! debian.vim
- "if filereadable("/etc/vim/vimrc.local")
- " source /etc/vim/vimrc.local
- "endif
- if &term=="xterm"
- set t_Co=8
- set t_Sb=^[[4%dm
- set t_Sf=^[[3%dm
- endif
- """""""""""""""""""""""""""
- " Use mouse on console
- """""""""""""""""""""""""""
- if has("wildmenu")
- set mouse =a
- endif
- " Set text-mode menu
- if has("wildmenu")
- " Use menu
- source $VIMRUNTIME/menu.vim
- set cpoptions-=<
- set wildcharm=<C-Z>
- map <F4> :emenu <C-Z>
- endif
- """"""""""""""""""""""""""""""
- " Tag list (ctags)
- """"""""""""""""""""""""""""""
- nnoremap <silent> <F8> :TlistToggle<CR>
- let Tlist_Ctags_Cmd = '/usr/bin/ctags'
- let Tlist_Show_One_File = 1
- let Tlist_Exit_OnlyWindow = 1
- let Tlist_Use_Left_Window = 0
- let Tlist_Sort_Type = 'name'
- let Tlist_Auto_Open = 1
- let Tlist_Auto_Update = 1
- let Tlist_WinWidth = 25
- let Tlist_Use_Right_Window= 1
- let Tlist_File_Fold_Auto_Close=1
- if $VIM_HATE_SPACE_ERRORS != '0'
- let c_space_errors=1
- endif
- """"""""""""""""""""""""""""""""
- " Window manager settings
- """"""""""""""""""""""""""""""""
- nmap wm :WMToggle<CR>
- map <c-w><c-f> :FirstExplorerWindow<cr>
- map <c-w><c-b> :BottomExplorerWindow<cr>
- let persistentBehaviour=0
- let winManagerWidth=25
- "if has("cscope")
- " set csprg=/usr/bin/cscope
- " set csto=0
- " set cst
- " 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
- " set cscopequickfix=s-,g-,c-,d-,t-,e-,f-,i-
- "endif
安裝taglist和winmanager
下載地址分別是:taglist winmanager
安裝方法嘛,下載頁已經說明了,我就偷個懶了。
安裝cscope_maps.vim
下載地址:cscope_maps.vim (另存爲就可以了)
安裝方法同taglist和winmanager(我都是直接放/usr/share/vim/vim73/下的相應目錄了,免得切換用戶麻煩)。
將下面的腳本保存到/usr/bin下,命名爲vimindex(名字我隨便起的,可以隨便改),附執行權限(chmod +x /usr/bin/vimindex)
- #!/bin/sh
- find $(pwd) -name "*.h" -o -name "*.c" -o -name "*.cc" > cscope.files
- cscope -bkq -i cscope.files
- ctags -R
好了,到這裏就配置好了,用vimindex生成索引文件開始瀏覽之旅吧。