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"}#!/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"}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="sh"}" 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{/code}
Page History
Date/CommentUserIPVersion
25 Jul 2008 (18:26 UTC)
xing62.47.234.23123
Current • Source
xing62.47.234.23122
View • Compare • Difference • Source
xing62.47.234.23121
View • Compare • Difference • Source
xing62.47.234.23120
View • Compare • Difference • Source
spiderr76.182.96.2218
View • Compare • Difference • Source
xing62.47.237.12614
View • Compare • Difference • Source
xing62.47.233.18513
View • Compare • Difference • Source
spiderr76.182.96.2212
View • Compare • Difference • Source
xing62.47.233.18511
View • Compare • Difference • Source
spiderr76.182.96.2210
View • Compare • Difference • Source
xing62.47.233.1859
View • Compare • Difference • Source
xing62.47.233.1858
View • Compare • Difference • Source
spiderr76.182.96.227
View • Compare • Difference • Source