Results 1 to 9 of 9

Thread: TAB for indentation in Gnome terminals

  1. #1

    Default TAB for indentation in Gnome terminals

    Hi,

    How to enable TAB button to indent in Gnome terminals? Very useful to have TAB button for indentation (with 4 spaces) in Gnome terminal for Python.

    Thank you.

  2. #2
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    11,293
    Blog Entries
    2

    Default Re: TAB for indentation in Gnome terminals

    To write code (python or otherwise), you have to first launch a text editor.
    If you launch vim for instance, you should find that TAB works as you expect.

    In other words, the functionality you're looking for shouldn't have any relationship with the terminal you're using (Gnome or otherwise), or if you think you should be able to do it, post what you're trying to do... It's likely that your code is being re-directed to something(like a HereDoc) before it can execute if it's more than one line (where you would have use to format).

    HTH,
    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  3. #3

    Default Re: TAB for indentation in Gnome terminals

    I'm just typing python in the terminal to get Python interpreter. In defining functions, cannot use TAB button to make indentation, and instead i have to use SPACE to make indentation.

    I would like to use TAB button for indentation with four spaces instead of SPACE bar with one space for indentation.

  4. #4
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    25,156

    Default Re: TAB for indentation in Gnome terminals

    What TSU already tried to explain is that the interpretation of a TAB character typed is done by the program running. This is not Gnome, it is not the Gnome terminal, but as long as you type bash commands it is bash. Now you seem to have started the Python interpreter, thus it is the Python interpreter that should do something with your TAB character (and you want to echo it with up to four space characters to a Tabbing point when I understand you correct). Thus you have to find out if Python supports this and when yes, how to set it.

    I am not a Python user, thus I do not know the answer, but I got the strong impression that you were looking in the wrong place (the terminal emulator program).
    Henk van Velden

  5. #5
    Join Date
    Jun 2008
    Location
    Groningen, Netherlands
    Posts
    19,852
    Blog Entries
    14

    Default Re: TAB for indentation in Gnome terminals

    Please use an editor, A terminal window is not fot writing python code. Write the script in a test.py file the run it the 'python test.py'. Inside test.py you can use indentation,
    ° Appreciate my reply? Click the star and let me know why.

    ° Perfection is not gonna happen. No way.

    https://en.opensuse.org/openSUSE:Board#Members
    http://en.opensuse.org/User:Knurpht
    http://nl.opensuse.org/Gebruiker:Knurpht

  6. #6

    Default Re: TAB for indentation in Gnome terminals

    Quote Originally Posted by hcvv View Post
    What TSU already tried to explain is that the interpretation of a TAB character typed is done by the program running. This is not Gnome, it is not the Gnome terminal, but as long as you type bash commands it is bash. Now you seem to have started the Python interpreter, thus it is the Python interpreter that should do something with your TAB character (and you want to echo it with up to four space characters to a Tabbing point when I understand you correct). Thus you have to find out if Python supports this and when yes, how to set it.

    I am not a Python user, thus I do not know the answer, but I got the strong impression that you were looking in the wrong place (the terminal emulator program).
    In Ubuntu Unity desktop, the TAB button used to work fine as a four-space indentation in Gnome terminal itself for bash commands and also in Python interpreter. In the pure Gnome desktop, the TAB button does not react [i.e. does nothing when you use TAB inside Gnome terminal].

  7. #7

    Default Re: TAB for indentation in Gnome terminals

    Quote Originally Posted by Knurpht View Post
    Please use an editor, A terminal window is not fot writing python code. Write the script in a test.py file the run it the 'python test.py'. Inside test.py you can use indentation,
    I am using Python interpreter for testing out small chunks of code, playing around with the code. Very easy and convenient to play with the code straight from Python interpreter.

    Sure i use an editor for scripts saving them in the .py files. But to quickly test one line statements or a few lines of code with the Python interpreter in the terminal is really convenient.

  8. #8
    Join Date
    Oct 2008
    Location
    Glasgow, Scotland
    Posts
    1,134

    Default Re: TAB for indentation in Gnome terminals

    Quote Originally Posted by ProgrammingLogic View Post
    I am using Python interpreter for ... But to quickly test one line statements or a few lines of code with the Python interpreter in the terminal is really convenient.
    You will need to modify your Python shell -- the one the “>>>” prompt.

    The Bash shell by default uses the tab-key for its tab-completion feature. If you install the Dash shell (zypper in dash), type “dash” at the Bash prompt (>), and then press <tab> or <ctl+i> at the Dash prompt ($) white-space equivalent to six spaces is insertd. If you enter the Python shell from Dash, the tab-key function is lost until you exit back to the Dash shell.
    ~Thank you for sharing an interesting problem.
    --
    slàinte mhath,
    rayH

  9. #9

    Default Re: TAB for indentation in Gnome terminals

    Thanks guys for the hints.

    Found the solution: https://www.thegeekdiary.com/linux-u...in-bash-shell/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •