Tab键Soft和Hard之分

这怪之前孤陋寡闻,在使用编辑器Atom时,进入设置看到Tab type(Tab类型),咦,tab还有Soft和Hard之分呀,Settings中关于Tab Type的提示如下:

Determine character inserted when Tab key is pressed. Possible values: “auto”, “soft” and “hard”. When set to “soft” or “hard”, soft tabs (spaces) or hard tabs (tab characters) are used. When set to “auto”, the editor auto-detects the tab type based on the contents of the buffer (it uses the first leading whitespace on a non-comment line), or uses the value of the Soft Tabs config setting if auto-detection fails.

根据上面内容可知,原来是在编辑文本文档时,当设置类型为Soft则按下Tab键插入空格符(个数便是tab size设置的大小),当设置为Hard则按下Tab键便插入一个Tab符,当设置为Auto的时候,编辑器便会根据所编辑文件内的风格进行设置,判断首次缩进位置所使用的风格。

其实,这也不难想到,Soft类型插入的缩进无论到哪儿大小肯定不变,会一直是你想要的样子,而Hard类型会根据在不同环境中设置的tab大小进行缩进,往往导致不统一,这对于强迫症的我简直不能忍,我还是希望编辑的代码到每个地方缩进是统一的,那么Soft才是我需要的,这印证一个说法:

Soft方式是绝对的,Hard是相对的。

无论什么类型,自己喜欢就好!


develop

463 字

2016-04-10 02:10 +0000