歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Unix知識 >> BSD >> FreeBSD下使用vim+cscope

FreeBSD下使用vim+cscope

日期:2017/2/28 11:23:41   编辑:BSD


FreeBSD的ctags沒有-R選項,迫使我嘗試cscope,感覺比ctags強很多。
安裝:
#cd /usr/ports/devel/cscope
#make install clean
#cd /usr/ports/editors/vim
#make WITH_GTK2=yes WITH_CSCOPE=yes install clean
配置:
QUOTE:.vimrc
" An example for a vimrc file.
"
" Last change: 2002 Sep 19
"
" To use it, copy it to
" for Unix and OS/2: ~/.vimrc
" for Amiga: s:.vimrc
" for MS-DOS and Win32: $VIM\_vimrc
" for OpenVMS: sys$login:.vimrc
" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
finish
endif
" Use Vim settings, rather then Vi settings (much
" This must be first, because it changes other options as a side effect.
set nocompatible
set autowrite
set nu
set cindent shiftwidth=4
set softtabstop=4
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
set autoindent
if has("vms")
set nobackup " do not keep a backup file, use versions instead
else
set backup " keep a backup file
endif
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")
" Don't use Ex mode, use Q for formatting
map Q gq
" This is an alternative that also works in block mode, but the deleted
" text is lost and it only works for putting the current register.
"vnoremap p "_dp
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
augroup END
else
set autoindent " always set autoindenting on
endif " has("autocmd")
:colo evening
if has("cscope")
set csprg=/usr/local/bin/cscope
" use both cscope and ctag for 'ctrl-]', ':ta', and 'vim -t'
set cscopetag
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
endif

使用:
在源碼書根目錄
#cscope -Rb
#vim xxx.c
然後就可以方便的ctrl+] ,ctrl + t 跳轉來。
Copyright © Linux教程網 All Rights Reserved