jump to navigation

Python + ViM May 9, 2011

Posted by PythonGuy in ViM.
add a comment

I really, really like ViM. I’ve only ever used a small subset of the features, just enough to do what I need and no more.

John Anderson at sontek.net posts a very convenient list of features and modules that make your ViM Python experience much more enjoyable. Right now, I’m trying to get PyFlakes to work, with little success.

My setup is pretty basic. I don’t use code folding, but I do use syntax highlighting. I tend not to stray from the basic keybindings, avoiding :map like the plague.

I do use splits a lot. On my dual-monitor setup, my left monitor is turned 90 degrees so it is 1080×1920. This allows me to view about 3-4 pages of code on a single screen. It also makes me move my head up and down.

Sometimes I’ll move the code to the other monitor to do a horizontal split to compare code—especially the vim diff mode.

I don’t use snippets. It’s really pointless, in my book. I guess I should now that I deal a lot with Mako, and Mako requires a closing tag. But I don’t, because it’s really not hard to type “i% if blah:% endif”. I do it with the HTML anyway. It’s rare that I write raw HTML out anyway.

I really want to get PyFlakes working. Syntax validation would save me a bunch of time. I can’t tell you how many times I’ve changed code, accidentally forgetting a comma or putting a comma where a period goes, only to have Python barf at me. Then I have to go digging in the logs to find the barf.

I also want to get the PEP 8 plugin working. This sounds like a good way to keep my code consistent.

Buffers are one of the coolest features of ViM. Not that other apps don’t have it, but because I can switch around the buffers without moving my hand from the keyboard. Say I’ve got a small change to make to 50 files, and it’s more than “perl -pi” can handle. I can open up the interesting files in ViM, setup a small script to do what I need done with ‘q’, and then hammer away, checking my work as I go. A small change to 50 files takes me about 20 minutes, because I don’t need to spend more than few seconds on each file. If I had to move my hand to the mouse for each file, it would likely take more than an hour.

Over time, my ViM skills have built up to the point where I really don’t know what I’m doing anymore. I just think, and it happens. If I had to pause and think about what keys to press, I would be far less efficient at what I do.

Advertisements