[Tutor] OT (probably): How to change default tab key value to 4 spaces in GNOME Terminal?

Peter Otten __peter__ at web.de
Sun Apr 26 05:18:27 EDT 2020


Peter Otten wrote:

> With readline you can do
> 
> import readline
> readline.parse_and_bind("TAB: '    '")

The moment I sent that suggestion I had a clever idea (I thought): Change 
Python's completer to insert 4 spaces if there's no text to complete yet.

But then I saw that this is already implemented for interpreters newer than 
my aging default 3.4:

[rlcomplete.py]
        if not text.strip():
            if state == 0:
                if _readline_available:
                    readline.insert_text('\t')
                    readline.redisplay()
                    return ''
                else:
                    return '\t'

You might try replacing the '\t's with '    ' though.



More information about the Tutor mailing list