During the PyPy sprint I've noticed that there are a lot of good development tools that people do not know about. There are also extremely convenient features of other tools that are also unknown. I think I should mention a few of them:
- Vim is a very powerful text editor. It takes some getting used to, but that time is well worth the increased productivity you get as a result. My usual programming environment is a GVIM window with the source code and a terminal window for running unit tests.
- Keyword completion in vim
- If you want to write clear code, you have to use clear names that are sometimes on the longish side. Instead of typing the whole name again and again, you can just type the first three or four characters and hit Ctrl+P. If there are several names with the same prefix, keep hitting Ctrl+P until you get the one you want. If you overshoot, use Ctrl+N which looks for matching names in the other direction. Vim looks for names in the current file, then in all opened files, then in tags and finally in all included files. You can also complete file names, whole phrases etc. Type :help ins-completion for a full help.
- Run ctags -R in the root of the source tree of a project. It
will build a tags database in a text file called "tags". The database
contains all names (functions, classes, etc.) defined in the source code and
locations of those definitions. Once in vim, type :tag somename and
vim will jump to the definition of somename. Alternatively, move
the cursor to a name and hit Ctrl+] to do the same. If the same name is
defined in several places, you can use
:tselto see a list of them all and choose the one you want to go to. Tags are also useful for keyword completion described above.
- GNU id-utils
- While tags let you quickly find the definition of a name, id-utils let you find all the places where that name is used. Think "grep on steroids". Usage is similair: run mkid in the project root to build a name database (a file named "ID"), then use gid name anywhere in the project tree to list all filenames and line numbers where name is mentioned. In vim you can :set grepprg=gid and use :grep name to perform queries and get a list of results in the error window (:cw).
Update: GNU id-utils ignore Python source files by default (boo!). To get around that, copy the example id-lang.map from the id-utils distribution to your home directory, add *.py text at the end, and alias mkid to mkid -m ~/id-lang.map.