History of Vim Tricks

Differences from version 10 to 23



@@ -1,10 +1,20 @@

+!vimrc tips
+* if you put these 2 lines in your vimrc, you can use :make to check your php code for typos: {code source="text"}set makeprg=php\ -l\ %
+set errorformat=%m\ in\ %f\ on\ line\ %l{/code}
+
+!cscope
 ^vim + cscope is insanely cool.^
+{attachment id=884 desc="This shell script" output=desc} will set up your machine with the stuff described below. all you need to do is download it, set the file executable and run it.
+{code source=Bash}
+curl http://www.bitweaver.org/liberty/download/file/884 -o vim-cscope
+chmod +x vim-cscope
+./vim-cscope
+{/code}
 
-!What's cscope?
+!!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
-
+!! 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

@@ -20,8 +30,8 @@

 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
+# {code source=bash title="get vim plugin"}mkdir -p ~/.vim/plugin/ && curl http://cscope.sourceforge.net/cscope_maps.vim | sed 's/\bcs add\b/" cs add/' > ~/.vim/plugin/cscope_maps.vim{/code}
+# Add the following to your ~/.vimrc (or /etc/vimrc for cool people) {code source="vim" title="~/.vimrc or /etc/vimrc"}" Some cscope specific settings
 if has("cscope")
  " Some scsope specific settings
  set cscopequickfix=s-,c-,d-,i-,t-,e-

@@ -63,6 +73,13 @@

  " easily reload cscope database
  nmap <F11> :cs reset<cr>
 endif{/code}
++ If you get an error message about a duplicate cscope database has been added, go to your ~/.vim/plugin/cscope_maps.vim file and comment out the section where it says{code source=sh num=41}
+ if filereadable("cscope.out")
+ cs add cscope.out
+ " else add the database pointed to by environment variable
+ elseif $CSCOPE_DB != ""
+ cs add $CSCOPE_DB
+ endif{/code}
 # To test if this worked:{code source="text"}
 $ cd /path/to/bitweaver
 $ vim wiki/index.php +/verifyPackage

@@ -70,3 +87,39 @@

  <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}
+
+!! Using it all
+Some funky tips on how to use your new setup (taken from cscope_maps.vim):
+{code source=text title="Mapping Overview"}
+The following maps all invoke one of the following cscope search types:
+
+ 's' symbol: find all references to the token under cursor
+ 'g' global: find global definition(s) of the token under cursor
+ 'c' calls: find all calls to the function name under cursor
+ 't' text: find all instances of the text under cursor
+ 'e' egrep: egrep search for the word under cursor
+ 'f' file: open the filename under cursor
+ 'i' includes: find files that include the filename under cursor
+ 'd' called: find functions that function under cursor calls
+
+To do the first type of search, hit 'CTRL-\', followed by one of the
+cscope search types above (s,g,c,t,e,f,i,d). The result of your cscope
+search will be displayed in the current window. You can use CTRL-T to
+go back to where you were before the search.
+
+Using 'CTRL-spacebar' (intepreted as CTRL-@ by vim) then a search type
+makes the vim window split horizontally, with search result displayed in
+the new window.
+
+Hitting CTRL-space *twice* before the search type does a vertical
+split instead of a horizontal one (vim 6 and up only)
+{/code}
+
+As you can see above, there's many new ways to now navigate your project. Very cool stuff happens when you move the curson over a function like __verifyPackage__ in wiki/edit.php and then do:
+# vim wiki/edit.php +/verifyPackage (open the file on the first occurrance of verifyPackage)
+# n (to move the cursor to verifyPackage)
+# <CTRL-\>s (this will search the database for all occurances of verifyPackage)
+# :copen (will open a window with a list of all occurrances of verifyPackage)
+# navigate to the occurrance you're interested in and hit <enter>
+# <CTRL-O> (move backward in your jump history - might need to hit this more than once to return to edit/wiki.php)
+# <CTRL-I> (move forward in your jump history)
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