Using tabs instead of spaces in IDLE?

Tim Peters tim.one at home.com
Wed Feb 13 23:29:43 EST 2002


[Tom Bryan]
> Is there a way to use tabs exclusively for indentation in IDLE?

Yes, provided you're happy with indentwidth==8.

> Basically, I'd like tabwidth to equal identwidth while permitting
> developers to adjust the indentwidth.

You're out of luck there, if they want anything other than 8 for both.

>  I see that AutoIndent.py says
>
> # indentwidth is the number of characters per logical indent level.
> # tabwidth is the display width of a literal tab character.
> # CAUTION:  telling Tk to use anything other than its default
> # tab setting causes it to use an entirely different tabbing algorithm,
> # treating tab stops as fixed distances from the left margin.
> # Nobody expects this, so for now tabwidth should never be changed.
> usetabs = 1
> indentwidth = 4
> tabwidth = 8    # for IDLE use, must remain 8 until Tk is fixed
>
> But I don't quite understand that explanation.

Don't be so timid <wink>:  change the code and see what happens.  The
meaning of the comment will soon become painfully clear.  Have you ever used
a word processor (as opposed to a text editor)?  Tk switches to "word
processor" tabs when you change its default tab setting.

> ...
> It doesn't look like IDLE is friendly to that type of customization.

Not exactly:  the Tk text widget is the hangup here.  IDLE's autoindent code
is shared by PythonWin, which latter, being based on the Scintilla text
widget, doesn't suffer the same tab surprises.

> I know that emacs is.  I'm currently investigating the other editors
> that my team uses, such as CodeWright.

CodeWright won't be a problem.  But stick to IDLE's default (== the Emacs
python-mode default), and no editor anywhere will be a real problem.





More information about the Python-list mailing list