Holy war
Holy war, a yarn.
Android good or IOS good, Windows good or Mac good, editor good or IDE good, underline good or underline good ...
Write code for so many years, you will encounter a lot of meaningless nonsense of the so-called brain residue controversy
Yesterday @willerce classmate just got into the job to ask a question:缩进用 Tab 还是空格的规范貌似没有啊?
Everyone suddenly realized that there was this problem ... At least prove it's not a big problem, or a little problem that hasn't been exposed.
Even... Because the unification was solved with IntelliJ idea automatically and in the dark.
With in-depth study, found that there is still a fastidious ...
Why do you want to use Tab?
按键次数
All of the learning tutorials I've seen, describing code indentation, is that by pressing a Tab, you're not pressing 4 spaces.
语义
tab means "indent a level", and spaces have a lot of meaning
文件更小
A Tab and a space are the same, 4 spaces is 4 times times
宽度可调整
Common is a Tab equal to 4 spaces, the reliable editor can be customized
Why do you use spaces?
- In all editors and systems, the
表现都是一致
width is determined only by the display font
- Programmers who can make
精确控制视觉呈现
the author more stooped will be able to draw the characters
语义
tab is a tab, which is not as scientific as the Table layout.
压缩后文件更小
Because the space is unavoidable, use Tab words to compress 2 kinds of characters (from the actual situation of the concept of the substitution)
Why do you mix it up?
简单
You can use it if you want to use it.
Tab 党搞不定行末注释对齐
They are the beginning of the indentation with Tab, line at the end of the comment alignment with a space
What exactly is Tab?
According to historical data, WikiPedia, the TAB key represents the tabulator key
tab key, it appears because the time to make a table to hit the space to knock a lot of time, and the content changes when the alignment is also more tangled, simply get a Tab click to jump a column.
Tab and Space in HTML
No matter how many consecutive Tab or space, when the page will be displayed as a space, K number is still a problem, but to walk gzip is not a problem, because gzip compression rate is particularly high for repetitive things.
Tab and space in CSS JavaScript
Have you ever written this neat CSS? If so, then Tab can only solve the line alignment, the end of the row only by space
Also, spaces can be resolved at the beginning of the line
Tab and spaces in comments
Have you ever written a note?
Well, is that really going to knock 4N down for a good look?
Basically the editor will have such a set of settings called 按一下 Tab 出来4个空格
, supporting theShift+Tab干掉4个空格
And of course the formatting is good-looking alignment.
Sublime Text 2
This excellent and lightweight editor is ideal for machines with poor performance, which is basically enough, and is set up by
It's going to be smart. Press TAB to enter 4 spaces, press BackSpace
backspace key to delete 4 spaces, non-header Tab still 4 spaces, but backspace delete each
But the problem with it is that shift+tab can only take effect when the cursor is at the beginning of a line or when a row is selected
IntelliJ idea
Because I SSD so run the IDE without pressure, basically what is IntelliJ idea, must be introduced.
PS: The same applies to Webstorm Phpstorm and other JetBrains home a series of Ides.
First, he defaults to typing Tab 4 spaces
Second, cursor positioning can be shift+tab in any position and forward
Finally, remember that note on the right side of the alignment, we give you a play
The following animations all press TAB only, minors do not imitate
First three lines tab out, line fourth press TAB to automatically align with spaces
The first three lines are the same as the initial position. Hold down the ALT button to drag into the column edit mode bulk operation
If line fourth goes first, the first three lines Tab adjustment will refer to the existing annotation alignment
It's hard to make you feel good.
Finally, a tip is included:
If the Align Value:on Conlon is set in the Code Style > CSS, click the Format shortcut key, and the second one is changed.
For students interested in Intellij idea
IntelliJ idea, Phpstrom, Webstorm Front-end development guide.
I choose a space
The conclusion is: press Tab to use the IDE to automatically generate alignment spaces
As once the Tab party, anti-live the space party so-called good-looking, semantic, open source projects, Twitter and so on, such as the use of space and so very subjective attack
Defeated by the alignment
What about you?
Original: Http://ooxx.me/tabs-vs-spaces.orz
Added
Know: When writing code, indentation using tab or space?
http://www.zhihu.com/question/19960028
English article "Smart Tabs": https://www.emacswiki.org/emacs/SmartTabs
Indent, Tab, or space? (GO)