.plan


@400000004a39324e1e481d04
Project: Code review tips for vim
Plan:

I have to spend a fair amount of my time doing source code review. I've
tried using tools like the hideous Source Insight, but for all its
flaws, I always come back to vim. There are a few things that I've been
adding lately though that have made it a bit more efficient. Here's what
I use:

exuberant ctags -- ctags are simple to use: exctags -R .

This creates a file called tags in the CWD. I have in my .vimrc simply
``set tags=tags'', so the one in the CWD is always used. At the top of a
source tree, I make the tagfile, start vim, and then use ``:Explore'' to
browse to the source files I want. ctags usage in vim is just ^] to jump
to a symbol definition, and ^T to go back.

cscope -- short story: cscope -R ^D

Once in vim again, you can go to a symbol and do ^\-s to see a lookup of
where that symbol is used in the codebase, or ^\-c to see callers. Pick
a number and you jump to it. Similar to ctags, ^T jumps back. You'll
want to put http://cscope.sourceforge.net/cscope_maps.vim into your
vim plugin directory for all of this to work.

Taglist -- The vim taglist plugin will show you a sidebar with all of
the symbols in a file and/or source tree, giving you a good overview and
letting you jump around. It's pretty simple to use, just remember ^W^W
switches between different vim panels. After you've installed it, (just
put it in your .vim/plugin dir), use ``:TlistToggle'' to activate it. Same
deal: after a jump, use ^T to go back on the stack.

NerdTree -- A nice and simple directory browser sidebar, with some extra
nifty features. Quite nice and actively maintained. Much better than :Ex.

flawfinder -- a hokey script, but it does most of the grepping for nasty
standard library functions that no one should be using. The neat thing
here is that you can use the output as a tool in vim. To do this, first
move your cscope.out and tags file somewhere else for a bit -- they
confuse flawfinder. Then, at the root of the source tree, do: 

flawfinder -SQD --followdotdir . > flawfile

Now, start up vim and do ``:copen'' to open up a ``QuickFix'' panel. Then do
``:cf flawfile'' to read in the flawfinder results. You now have a browsable
list of issues that you can run through. ``:cn'' goes to the next hit. Now
that you see what a hitlist looks like, you can use this for other stuff
too -- the format is trivial.

Of course there are a huge number of handy vim tricks. It's actually
worth reading the :help, as it's surprisingly usable and enlightening.
You might also want to check http://vim.wikia.com/wiki/Best_Vim_Tips
for some other handy tips.

Comment Link