Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are hard and soft tabs?

I hear the term "hard tabs" and "soft tabs" (often with much debate about which is better), but what do the two terms actually mean? I am looking for a simple definition of "soft tabs" and "hard tabs".

like image 294
Keavon Avatar asked Oct 13 '14 23:10

Keavon


People also ask

Why tab is 8 spaces?

Because the default tab size in Linux console is 8 spaces, and therefore most CLI text editors in Linux also default to 8 spaces.

How wide should a tab be?

The default value for the tab-size property is 8 space characters, and it can accept any positive integer value. He are some examples of the various ways tab-size can be used: HTML.

What is the tab character?

A tab character defines the space between two document elements. For example, you can separate numbers from list items, or columns of text, by using tabs. You can then set tab stops that define the location and alignment of the tabbed text. Click to view larger image. You can align text in different ways by using tabs.

How many spaces r in a tab?

And as demonstrated from the REPL it shows that a tab is the equivalent of 4 spaces.


2 Answers

Hard tabs use the tab character, http://en.wikipedia.org/wiki/Tab_key#Tab_characters

Soft tabs are just spaces. Soft tabs are usually either 2 or 4 spaces, depending on convention.

If you set your editor to use "soft tabs," when you press the Tab key on your keyboard your editor will insert spaces instead of the tab character.

like image 153
radiantradon Avatar answered Oct 19 '22 19:10

radiantradon


Hard tabs are the equivalent of using the tab key to tab your code while soft tabs are spaces added in to emulate a tab either manually or via a code editor like Sublime Text. There are some who believe that soft tabbing is better for readability for larger teams that use different text editors since some editors will give different spacing for hard tabs, but I think you can use either one as long as you stick to one and use it consistently. In the end, this mostly comes down to personal preference.

like image 24
geno_blast Avatar answered Oct 19 '22 20:10

geno_blast