MacPython Logo from __future__ import *

buy music albums Silver Apples buy mp3 albums Tarrus Riley buy tracks mp3 Kravits buy Reaper albums mp3 buy Kravits albums music buy music Evita CD online albums mp3 Silver Apples download Madonna CD music buy tracks music Kravits download music albums Silver Apples

2003-11-14

Stupid vim tricks

Filed under: python, vim — bob @ 3:02 pm
In some projects, like PyObjC, the coding style is to use tabs in C/Objective-C code, and spaces in Python. I'm lazy, and haven't set it to do this on load, and I often forget to :set noet (not expand tabs) in vim. The quick trick I use to convert tabs to spaces (or vice versa) is to:
  • set/unset et as appropriate
  • make sure my sw (shiftwidth) and ts (tabstop) are both 4 (this is in my .vimrc)
  • indent the block of code once (this converts, but gives me extra indent) with > in visual mode
  • dedent it with < in visual mode

Voila, the whole mess is now converted from tabs to spaces or vice versa. Here's what I find to be comfortable in my .vimrc (I do have some custom stuff for python, pyrex, coloring, etc. but that's not as important):

set ffs=unix,dos,mac
set ts=4
set bs=2
set et
set sw=4
set sm
set sta
set sts=4
set ai

Powered by WordPress