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-update__ and __chmod 755 /usr/local/bin/cscope-php-update__{code source="bash" title="/usr/local/bin/cscope-php-update"}#!/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
# Remove duplicate add code from ~/.vim/plugin/cscope_maps.vim{code source="text"}
" 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{/code}
# 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

" easily reload cscope database
nmap <F11> :cs reset<cr>
endif{/code}
# To test if this worked:{code source="text"}
$ cd /path/to/bitweaver
$ vim wiki/index.php +/verifyPackage
move your cursor over verifyPackage
<CTRL-\>g will go to where the function was defined
<CTRL-\>s will show all places where the function has been used
use ':copen' to view the complete list.{/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