Vim Setup For Working With Large Codebases
Vim is awesome for working with small projects where you know where everything is. What if you don’t? Here’s my current setup, as a form of backup. Hopefully this is useful to someone else as well.
ctags setup:
#!/bin/sh
cd basedev
ctags -R --totals=yes --tag-relative=yes \
--extra=+f \
--PHP-kinds=+cf \
--regex-PHP='/abstract class ([^ ]*)/\1/c/' \
--regex-PHP='/interface ([^ ]*)/\1/c/' \
--regex-PHP='/(public |static |abstract |protected |private )+\s*function\s+([^ (]*)/\2/f/'
.vimrc:
nmap <C-f> :NERDTreeToggle<CR> nmap <C-b> :BufExplorer<CR> nmap <C-t> :TlistToggle<CR>
Installed VIM plugins:
So to open a file in the source tree, I can just:
cd ~/code/basedev :tag SomeClassName
And then the rest of my workflow is:
Control+f = Toggle the file explorer tree Control+b = Pick an open file to edit Control+t = List functions in the file (Control+w to change windows) Control+] = Jump to tag under cursor :Ack Foo = Look for files that contain Foo and potentially open them
All of this works without dealing with vim split windows or tabs, which are, IMHO, both very annoying.
Simple, and works. And, best of all, it is not Eclipse.
Suggestions on your other favorite vim plugins are very welcome. While Ack is nice on the command line, I think there are probably better file search plugins for vim that people prefer?. I am not using any “project” style plugins at the moment. My workflow for remembering a workspace is, so far, writing down the names of classes I’ve found along the way that might be worth remembering, and opening them again with “:tag Foo” as needed. I’ll edit this page over time to reflect my current setup.
Hope you had a good vacation.. I am more an emacs person.. My only knowledge of vim is to edit the makefiles for emacs
.
Actually that and my old Unix friends telling me its not real vi because:
A) It has plugins and might as well be emacs.
B) It uses a ton of memory and might as well be emacs.
[This was after one of them played around and supposedly oom'd their machine with one too many vim extension. But these guys think 64 MB is a humongous process.]
Anyway, have a good week.
Stephen Smoogen
November 11, 2009 at 12:20 am
Hmm, good old Escape Meta Alt Control Shift.
Michael DeHaan
November 11, 2009 at 12:31 am