History of Vim Tricks
^vim + cscope is insanely cool.^
!What's cscope?
cscope will generate a list of functions used in bitweaver and you can use a few keymaps to very quickly jump to those functions from within bitweaver (or any source code tree). cscope is faster and more feature rich than ctags.
!Setting it up
# Install cscope (via rpm, etc)
# Add this file to __/usr/local/bin/cscope-php__ {code source="bash" title="/usr/local/bin/cscope-php"}#!/bin/bash
for arg in "$@"; do
if [ -d $arg ]; then
#echo Create list of php files in cscope.files
find $arg \( -name "*.php" -or -name "*.tpl" \) -and -not -regex "./temp/.*" -and -not -regex ".*/language.php" -print > $arg/cscope.files
#echo Create cscope database in cscope.out
cscope -b -i $arg/cscope.files -f$arg/cscope.out
rm -f $arg/cscope.files
else
echo "Directory not found: $arg"
fi
done
{/code}
# Have a periodic crontab like:{code source="bash" title="cronjob"}0 * * * * /usr/local/bin/cscope-php /path/to/project1 /other/path/to/project2{/code}
# mkdir -p ~/.vim/plugin/ && curl -o ~/.vim/plugin/cscope_maps.vim http://cscope.sourceforge.net/cscope_maps.vim
# Add the following to your ~/.vimrc (or /etc/vimrc for cool people) {code source="vim" title="~/.vimrc or /etc/vimrc"}" Some scsope specific settings
if has("cscope")
" Some scsope specific settings
set cscopequickfix=s-,c-,d-,i-,t-,e-
" always use cscope instead of tags
set cst
" path to cscope
set csprg=/usr/bin/cscope
" search databased before searching tag files
set cscopetagorder=0
" don\'t display cscope messages when adding database
set nocsverb
" add any database in current directory
if filereadable("cscope.out")
cs add cscope.out
" else search up a few directories
elseif filereadable("../cscope.out")
cs add ../cscope.out
elseif filereadable("../../cscope.out")
cs add ../../cscope.out
elseif filereadable("../../../cscope.out")
cs add ../../../cscope.out
elseif filereadable("../../../../cscope.out")
cs add ../../../../cscope.out
elseif filereadable("../../../../../cscope.out")
cs add ../../../../../cscope.out
" else add database pointed to by environment
elseif \$CSCOPE_DB != ""
cs add \$CSCOPE_DB
endif
" reset cscope verbosity
set csverb
endif{/code}
!What's cscope?
cscope will generate a list of functions used in bitweaver and you can use a few keymaps to very quickly jump to those functions from within bitweaver (or any source code tree). cscope is faster and more feature rich than ctags.
!Setting it up
# Install cscope (via rpm, etc)
# Add this file to __/usr/local/bin/cscope-php__ {code source="bash" title="/usr/local/bin/cscope-php"}#!/bin/bash
for arg in "$@"; do
if [ -d $arg ]; then
#echo Create list of php files in cscope.files
find $arg \( -name "*.php" -or -name "*.tpl" \) -and -not -regex "./temp/.*" -and -not -regex ".*/language.php" -print > $arg/cscope.files
#echo Create cscope database in cscope.out
cscope -b -i $arg/cscope.files -f$arg/cscope.out
rm -f $arg/cscope.files
else
echo "Directory not found: $arg"
fi
done
{/code}
# Have a periodic crontab like:{code source="bash" title="cronjob"}0 * * * * /usr/local/bin/cscope-php /path/to/project1 /other/path/to/project2{/code}
# mkdir -p ~/.vim/plugin/ && curl -o ~/.vim/plugin/cscope_maps.vim http://cscope.sourceforge.net/cscope_maps.vim
# Add the following to your ~/.vimrc (or /etc/vimrc for cool people) {code source="vim" title="~/.vimrc or /etc/vimrc"}" Some scsope specific settings
if has("cscope")
" Some scsope specific settings
set cscopequickfix=s-,c-,d-,i-,t-,e-
" always use cscope instead of tags
set cst
" path to cscope
set csprg=/usr/bin/cscope
" search databased before searching tag files
set cscopetagorder=0
" don\'t display cscope messages when adding database
set nocsverb
" add any database in current directory
if filereadable("cscope.out")
cs add cscope.out
" else search up a few directories
elseif filereadable("../cscope.out")
cs add ../cscope.out
elseif filereadable("../../cscope.out")
cs add ../../cscope.out
elseif filereadable("../../../cscope.out")
cs add ../../../cscope.out
elseif filereadable("../../../../cscope.out")
cs add ../../../../cscope.out
elseif filereadable("../../../../../cscope.out")
cs add ../../../../../cscope.out
" else add database pointed to by environment
elseif \$CSCOPE_DB != ""
cs add \$CSCOPE_DB
endif
" reset cscope verbosity
set csverb
endif{/code}