Question

Actually gnome-terminal display tabs as 8 spaces, and this is very annoying when you cat files or view diffs, is there some way to change this permanently?

Was it helpful?

Solution 2

The unique solution I found is to type in terminal:

tabs 5,9,13,17,21,25,29,33,37,41

and append it to ~/.bashrc if you want permanent changes.

PS: This obviously cover up to 10 tab indents.

OTHER TIPS

Instead of writing out an explicit list of tabstops, you can also use implicit intervals:

tabs -n

This will set tabstops to occur every n columns. For more information, check out the manpage for tabs at http://manpages.ubuntu.com/manpages/maverick/en/man1/tabs.1.html.

You need to set the tabwidth on the underlying tty, not in gnome-terminal itself.

Theoretically, you should be able to use 'setterm -regtabs 4' to set the tabwidth to 4 in your .bashrc.

Doesn't seem to be working on my linux distro, but it works when I ssh from a remote system.

The easiest way to reset the tabwidth to 8 is to use 'tabs -8' (tabs -d8 to get a visual of the change).

The problem with doing it as "tabs -4" is that the first tab stop is off by one (at least on my system). If I type in "tabs -4", for example, the first tab stop will start in the 4th column with 3 blank spaces in front of it instead of 4. Subsequent tab stops will all be correctly separated by 4 spaces. A workaround to this is to specify the tab stops like so:

tabs 1,+4,+4,+4,+4,...

You can also do tabs -4 and it will set a tab stop every 4th column.

If you're using bash, this is what I have in my ~/.bashrc:

# set tabs to width TABWIDTH
TABWIDTH=4
# for less(1) the option -x4 was added (see above);
# other programs may need their own flags
setterm -regtabs ${TABWIDTH} </dev/tty
tabs -0 </dev/tty
# this erroneously imho sets the first tab at offset 3, not offset 4:
#tabs 1,+${TABWIDTH} </dev/tty
# this works:
tabs 1`for i in {0..40}; do echo -n ",+${TABWIDTH}"; done`
unset TABWIDTH

Note the backticks around the 'for ... done' ditty.

edit: The last '+4' before the 'done' statement should of course have been +${TABWIDTH}.

tabs 1,5,9,13,17,21,25,etc doesn't appear to work entirely correctly. On input, when backspacing over a tab, gnome-terminal goes back 8 spaces, not four. Looks like there's a gnome-terminal bug here. (Note: you won't see this if typing into the shell, because it usurps tabs for file completion. You have to first run cat or dc or some other command that doesn't arrogate tab characters for its own purposes.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top