teaching machines

Vim Autotemplates

When I create a brand new file in Vim, I automatically insert template text into it. For Java, the template looks like this: public class CLASS { CURSOR } The C template looks like this: #include <stdio.h> #include <stdlib.h> int main(int argc, char **argv) { CURSOR return 0; } The HTML template looks like this: […]

You won’t believe what happens when you type these 19 things into Vim!

A student group at my university asked me to come talk about Vim at their upcoming meeting—which was two days away. I said no. Then they wised up and asked me to speak at a meeting sometime next semester. I said okay. Following are 19 of my favorite Vim editing tricks. Insert Mode Complete filenames […]

Quick Commenting in Vim

Speedy commenting is a major feature of any IDE like Vim. I’m sure there are good plugins that support it, but I don’t like other people’s code. I wrote my own, and here it is, ready for you to not like it. It works on the premise that for each type of file you have, […]

Automatic Alias Creation in Mutt/Vim

A friend has got me thinking about using Mutt again. I gave it up years ago after I was forced to use IMAP for one of my mail accounts, and I didn’t think Mutt was up to the task. I switched to Thunderbird, which lets me do certain things faster. However, I’ve really missed a […]

Restoring the Last Known Cursor Position in Vim

In unconfigured Vim, the cursor is placed at the beginning of each file that I open. When I close a file in Vim and open it again later, it’d be really nice if the cursor would automatically move to where I left off editing. And it can, with this handy autocommand: Autocommands let you write […]

Swapping first_second to second_first in Vim

When I write C code, I never know how to name functions. In an object-oriented language, my methods are verbs: add, insert, get, swashbuckle, and so on. The subject or indirect object of these verbs is an instance of the containing class, making my code read like English sentences: vector.add, list.insert, image.get, swashbuckler.swashbuckle. In C, […]