Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change tab width in git diff? [duplicate]

The standard spacing for a tab is 8 characters.

I prefer to view that as 4 characters in my editors and console. I can easily change this default behavior on console with the tabs command:

tabs -4 

However, when using git diff or git show it displays in the default 8 character tab whitespace.

How can I get git diff to render tabs as 4 character spaces?

like image 443
Jeff Puckett Avatar asked Sep 06 '16 15:09

Jeff Puckett


People also ask

How do I change the size of a tab in GitHub?

2021, you can set the tab size directly in your GitHub settings: github.com/settings/appearance . Announced in Changelog "Tab size rendering preference".

Does GitHub use tabs or spaces?

You can manage the number of spaces a tab is equal to for your personal account. If you feel that tabbed indentation in code rendered on GitHub takes up too much, or too little space, you can change this in your settings.


1 Answers

This actually has nothing to do with git diff.

git diff actually renders a tab, which is later converted by your terminal emulators (for instance, gnome-terminal) to spaces.

Go to the preference of your terminal emulator to change that setting.


Also, git may use a pager, so you might want to configure it like that:

git config --global core.pager 'less -x1,5' 

More information here: setting tabwidth to 4 in git show / git diff

like image 65
blue112 Avatar answered Oct 03 '22 00:10

blue112