Programmers Editor

Alan Daniels daniels at mindspring.com
Sun Sep 12 22:55:02 EDT 1999


On 9 Sep 1999 18:42:51 GMT, the infinitely wise Bernhard Reiter
(bernhard at alpha1.csd.uwm.edu) spoke forth to us, saying...

>Someone should elaborate on the tab use in vim a bit.

I set up the following in my .vimrc file:
set list
set listchars=tab:#^
set noexpandtab

"list" says to show otherwise non-viewable characters, such as tabs,
newlines, or trailing spaces. "listchars" sets what those should show
up as -- in my case, I'm just interested in seeing all tabs as
something like "#^^^^^". The "noexpandtab" tells VIM to insert spaces
rather than an actual tab character.

The overall effect is that tab characters never make it into my source
code. Tabs are bad, bad, bad. And, with "list" turned on, I can
immediately see if any snuck in there, or (horrors), I have the source
code of others that has tabs in them. A simple...

:%s/\t/    /gc

...turns all of your tabs into spaces.

Of course, this means I usually trip up when handling Makefiles
(which, if you'll remember, really DO need actual tab chars), but the
benefit is worth the occasional headache. :=)

Also, if you're brave enough, you can compile VIM with a
--python-enabled option under "./configure", which will let you run
python code without leaving the editor (Hey! Almost like Emacs!). This
may sound complicated, but if you're using VIM to begin with you
obviously have a pathological lack of any fear of complexity to begin
with. :=) The interface will let you type stuff like...

:py print "Hello world!"

...and Python is fired up for you. The downside is, it's only good for
one-liners, so you can't do anything too complicated. I can only
surmise that this feature was added in the same spirit as VIM's ":pl"
command for Perl. :=)

-- 
=======================
Alan Daniels
daniels at mindspring.com
daniels at cc.gatech.edu




More information about the Python-list mailing list