33

When I press tab in terminal it goes very far. So I would like to change tab width, make it smaller. Anyone could help me, please?

Templar
  • 981
  • 3
  • 13
  • 25

2 Answers2

41

You can set the tab width on any terminal to 4 (for example) by using the following command:

tabs -4

You can also set an explicit tablist. Consider looking at the man page.

Talia
  • 510
  • 4
  • 5
  • 3
    This breaks `scp` and `rsync` on Ubuntu 19, i.e., `scp myfile.txt user@ubuntu19:/tmp/`, if the `ubuntu19` has `tabs -4` on its `~/.bashrc` file. Instead, use `[[ $- == *i* ]] && tabs -4` on your `~/.bashrc` and this problem will be fixed because it will make the command only run on interactive shells: [Getting stty: standard input: Inappropriate ioctl for device when using scp through an ssh tunnel](https://stackoverflow.com/questions/24623021/getting-stty-standard-input-inappropriate-ioctl-for-device-when-using-scp-thro) – user Dec 03 '20 at 18:52
  • Thanks for the tip. – Talia Dec 05 '20 at 00:55
5

If you are referring to using the Tab key in the terminal, I found this at UF. Ubuntu Forums Thread #7788701:

A possibility is setting the spacing in the application you are using via the terminal. For example in vim - :set tabstop=4 .

Or you could look into the man page for the expand command with man expand. Example of usage - expand -t 4 mytextfile.txt - this would convert the tab spacing when viewing a file from the default 8 to 4.

Nitin Venkatesh
  • 21,993
  • 11
  • 68
  • 91