Compare source code

Tim Chase python.list at tim.thechases.com
Sat Nov 6 08:00:20 EDT 2010


On 11/06/10 03:27, Seebs wrote:
> On 2010-11-06, Steve Holden<steve at holdenweb.com>  wrote:
>> If someone were to use a text editor which had always historically
>> mangled whitespace I would find myself wondering why they found it
>> necessary to restrict themselves to such stone-age tools.
>
> I have yet to find an editor that allows me to, well, *edit*, more
> comfortably than vi.
>
> As to what it does with whitespace... What it does is exactly what
> is most desireable in every other kind of file I edit.  I wouldn't
> normally refer to it as "mangling" in the pejorative sense; it mostly
> leaves spaces alone, but when preserving indentation from one line
> to the next, uses tabs.  That, it turns out, is useful and desireable
> in nearly all programming languages, and in particular, in all
> the other programming languages I use.

I think in a previous thread, you mentioned that you use nvi. 
While I can't speak to the knobs-and-dials that nvi offers, in 
vim, you can twiddle the 'expandtab' option (along with the 
associated 'tabwidth' and 'shiftwidth' settings) to get whatever 
behavior is deemed "correct" for the project you're working on. 
So if I'm working on a project with PEP-8 4-spaces-per-indent, I'll

   :set sw=4 ts=4 et

and then if the file erroneously has tabs in it, I'll just issue

   :retab

to fix it[1].

-tkc


[1]
Yes, if you have string literals with tabs that you want to keep 
in them, the solution is a little more complex, but doable; 
though in such cases I'd recommend using "\t" instead of a 
literal tab.







More information about the Python-list mailing list