LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   A question about the default tabstop in bash being 8. (https://www.linuxquestions.org/questions/linux-newbie-8/a-question-about-the-default-tabstop-in-bash-being-8-a-747534/)

joeBuffer 08-14-2009 09:04 AM

A question about the default tabstop in bash being 8.
 
The default tabstop in bash is 8. Is there a good reason for this? If not, how do you change it?

pixellany 08-14-2009 09:15 AM

I just Googled and found one thread which rambled on about why you should not change it, but never talked about how TO change it. Pretty soon they were talking about how missionaries tried to change Bulgarian grammar. Now I have a headache......

Perhaps it is in the PS1 env. variable? Why can't I do "man PS1" on my machine? ARRRRRRRRRRRGH!!

pixellany 08-14-2009 09:20 AM

https://www.linuxquestions.org/quest...set-it-322368/

catkin 08-14-2009 09:25 AM

I guess the origins of tab stops every 8 characters are in typewriters and thence in teletypes which were the commonest terminal in the early days of UNIX. Neither typewriters not teletypes had standardised tab stop positions but 8 was chosen as the commonest value.

Bash itself does not define the tabstop spacing; do you mean the terminal's tabstop spacing?

There's some relevant info here.

joeBuffer 08-14-2009 09:32 AM

That's what I meant, the terminal. I don't really know.
Quote:

If your terminal has tabstops set at 12 characters, the same file would look like this:
How could you change your terminal tabstop setting?
I would assume it's the programs themselves that are doing it, I guess. I thought maybe it's altered in some way by something. I looked at that site, and it said "If your terminal has tabstops, etc." like I just quoted. The cat output was changed when the tabstop setting was different. I looked at the thread you posted the link to here, and used the setterm -regtabs 4 and it didn't change my cat output. The tabstops are still 8.

catkin 08-14-2009 09:34 AM

Quote:

Originally Posted by joeBuffer (Post 3643241)
That's what I meant, the terminal. I don't really know.

How could you change your terminal tabstop setting?

You could read the LQ thread link posted by pixellany.

joeBuffer 08-16-2009 10:40 PM

I read it, it's just one of those questions where everyone's answer for it differs, and using their suggestions doesn't appear to work. I assumed that maybe it wouldn't be possible, since it would be the program doing it, and not bash or the terminal. I tried a couple of things that people suggested, and it wouldn't work. I wouldn't really mark this as solved, since I still don't see how you could do it really ... but I guess it's not too big of a deal.

catkin 08-17-2009 02:46 AM

What sort of terminal are you using? According to the setterm man page, -regtabs (an its other tab controls) only work on virtual terminals.

That makes sense; only when the terminal device is controlled by Linux itself can it control the tab stops. For other terminal types -- hardware (!) and hardware emulators including terminals in graphical windows -- then it's the device itself that has to be configured. How to do that is dependent on the device itself. What sort of terminal are you using?

joeBuffer 08-17-2009 07:36 AM

On this page, it says that if the tabstop is changed, the tabs using cat will be changed:
http://hell.org.ua/Docs/oreilly/unix/upt/ch41_04.htm
That's the web page you gave for information.
---
I'm using gnome-terminal.
Code:

joebuffer@ubuntu:~$ tty
/dev/pts/1
joebuffer@ubuntu:~$ echo $TERM
xterm
joebuffer@ubuntu:~$ cat .vimrc
set nocompatible
syntax on
set tabstop=4
set bs=2
set number
joebuffer@ubuntu:~$ vim tabstop4_example
joebuffer@ubuntu:~$ cat tabstop4_example
abc
        def
                ghi
joebuffer@ubuntu:~$ cat > cat_example
abc
        def
                ghi
joebuffer@ubuntu:~$ setterm -regtabs 4
joebuffer@ubuntu:~$ cat tabstop4_example
abc
        def
                ghi
joebuffer@ubuntu:~$ cat > cat_example
abc
        def
                ghi


catkin 08-17-2009 09:21 AM

The tabstops set in vi only control how vi displays them; it doesn't affect the saved file which simply contains tabs. regtabs only controls virtual terminals. I believe those are the ones you get using Ctrl+Alt+F[1-6] so does not include gnome-terminal.

Did you try the tabs command as suggested here?

Another avenue to try is termcap. gnome-terminal settings are affected by the termcap settings in /usr/share/vte/termcap/xterm. I think hts is used to define tabstops ...

joeBuffer 08-17-2009 09:50 AM

Thanks for your help, I'm sure this is all the information I need. I'm gonna mark this as solved, because I have the information I personally needed, but I haven't done this. I haven't gotten it to work yet, but I know this is all the information I really needed to help me solve this problem. I just wanted to be pointed in the right direction at least, and have a yes/no answer as to whether or not it could or should be done.


All times are GMT -5. The time now is 01:13 AM.