Vim, Watch, Wmii

by Volker Diels-Grabsch

This is the summary of a short, unprepared talk I gave on 2012-01-17 at the Berlin PHP UserGroup. In that meeting, everyone was invited to present their favourite editor or IDE. So I demonstrated my current way of doing things.

Created 2012-01-17, Last updated 2012-01-17
Articles

Vim

I'm using mostly Vim, although I'm a big fan of Emacs, too.

Those editors are said to be hard to configure. But there is no need for complicated editor configurations! Your ~/.vimrc can be as simple as:

syntax on
set modeline

Then, everything else will be configured automatically as long as your source files contain a special comment, the Vim modeline. For instance, if your PHP coding style says to never use tabs and to indent each level with 4 whitespaces, your source files could start with:

<?php
// vim: set expandtab softtabstop=4 autoindent:
...

The Emacs File Variables provide a similar feature.

Watch

I'm using Watch to automate running my tests while I'm coding.

Imagine you are working on a complicated feature and have some testing code in the test.php file. Then, just open a separate terminal window, place it below your editor, and run:

watch php test.php

That will start the "php test.php" command every 2 seconds. Well, a lag time of 2 seconds is a bit annoying, so you should speed this up via the -n switch:

watch -n0 php test.php

Note that this won't burn your CPU. It will still wait for 0.1 seconds before each repetition.

This setup is very convenient. You just work on your code, hit save, and the test results show up immediately. Also, if you made a syntax error you'll notice that very quickly.

A similar feature in the browser would be great! But for some inexplicable reason, almost no browser seems to provide auto-reloading out of the box, Opera being a notable exception. At least there are various Firefox Add-ons and an autoreload bookmarklet that works with most browsers.

Wmii

I'm using Wmii, which is a tiling window manager.

Some people say that tiling window managers are the only real window managers, because those actually manage your windows. There's some truth in it: If you make one window larger, the rest is adjusted automatically. You don't have to resize and position each window individually, although when necessary you can do that, too.

In case you've never played with it, this video about Wmii might give a surface impression.

Conclusion

Using a good editor, auto-reloader, and window manager removes a lot of pain that normally drives people into using an IDE. Plus, those tools are generic and thus "integrate" automatically with any other tools you want to use. ;-)