(GitHub)为自己的Repository设置默认tabsize

GitHub默认显示tab为8个空格的大小,若想要改为4个怎么办呢?


 1、别人的Repository

要么浏览器URL中添加后缀?ts=4,要么安装浏览器扩展或自己配置css。

2、自己的Repository

GitHub是支持EditorConfig的。只需在你的Repository根目录下(注意不是.git文件夹下)新建文件

.editorconfig

# top-most EditorConfig file
root = true

# all files
[*]
indent_style = tab
indent_size = 4

注意,该配置文件不仅仅对浏览有效,在线编辑时也是有效的。

indent_style: 可以是tabspace。tab是hard tab,space为soft tab(按下的是Tab键,出来的实际是空格)。

indent_size: 缩进的宽度,即列数,整数。如果indent_style为tab,则此属性默认为tab_width。

tab_width: 设置tab的列数。默认是indent_size。

注意indent_size和tab_width的区别。后者是文档中tab字符显示出来的宽度,包括已存在的tab字符和编辑中插入的tab字符。如果indent_style是space,那么编辑中按TAB键出来不再是tab字符而是indent_size个空格了。。。别问我如果indent_style是tab,但indent_size/tab_width不同时按TAB键的显示宽度是多少。。。

 

当然,.editorconfig的作用绝不仅如此。

 

[参考链接]:

http://stackoverflow.com/questions/8833953/how-to-change-tab-size-on-github

http://editorconfig.org/

http://www.cnblogs.com/xiyangbaixue/p/4201490.html

posted @ 2017-03-31 11:09  sfqtsh  阅读(2406)  评论(0编辑  收藏  举报