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

相关文章:

  • 2021-11-13
  • 2021-10-05
  • 2021-04-19
  • 2022-02-09
  • 2022-01-22
  • 2021-10-23
  • 2021-05-08
猜你喜欢
  • 2022-02-08
  • 2021-04-03
  • 2021-11-14
  • 2021-08-05
  • 2021-12-04
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案