基于文件扩展名的自定义选项卡大小
Custom tab size based on file extension
为了和同事相处得更好,我给 atom 配置了 2-space 标签,但在某些文件中,我更喜欢 4。我正在尝试计算另一种文件类型,在这种情况下,我的 Foo.pro 个文件是用 Qt Creator 创建的。
我已经尝试了几十种方法,但似乎没有任何效果。我正在编辑我的 ~/.atom/config.cson
,然后重新启动 atom,但没有任何变化。
这是我最近的尝试:
"*":
core:
customFileTypes:
"source.pro": [
"pro"
]
disabledPackages: [
"autocomplete-plus"
"markdown-preview"
"markdown-preview-plus"
"spell-check"
]
telemetryConsent: "limited"
themes: [
"atom-light-ui"
"one-light-syntax"
]
editor: {}
"exception-reporting":
userId: "283f523f-3348-4956-97f6-a73675e6e9c6"
"tree-view":
hideVcsIgnoredFiles: true
welcome:
showOnStartup: false
".basic.html.text":
editor:
tabLength: 4
".html.source":
editor:
tabLength: 4
".source.pro":
editor:
tabLength: 4
".shell.source":
editor:
tabLength: 4
".shtml.source":
editor:
tabLength: 4
我相当确定其中一些其他人也没有工作。在 Atom 中,如果我打开我的 .pro 文件并执行 Alt-Cmnd-P,它说文件类型是 text.plain.null-grammar
。制表符宽度仍然是 2 个字符。很明显我做错了什么。
您会注意到我正在尝试定义自定义文件类型(在顶部),然后定义制表符长度(在底部附近)。
看来,Atom 颠倒了 config.cson
中语言的作用域,因此与其使用 .source.pro
,不如使用 .pro.source
(与您的示例中的其他语言一样)。至少当您在包设置中为一种语言设置缩进时,它就是这样做的。
既然您提到您想与同事更好地相处:您是否考虑过使用与编辑器无关的 EditorConfig 标准来与他们共享缩进设置?每当您的项目包含 .editorconfig
文件时,这将覆盖您在不存在此类文件时将使用的个人首选项。 许多 编辑器直接或通过插件支持 EditorConfig。
您似乎需要为 .pro 文件安装语法,例如 language-qtpro
,否则 source.pro
作用域将不会激活。
(我相信这是因为 the fileTypes
field of a grammar package, which activates the scopeName
field。)
为了和同事相处得更好,我给 atom 配置了 2-space 标签,但在某些文件中,我更喜欢 4。我正在尝试计算另一种文件类型,在这种情况下,我的 Foo.pro 个文件是用 Qt Creator 创建的。
我已经尝试了几十种方法,但似乎没有任何效果。我正在编辑我的 ~/.atom/config.cson
,然后重新启动 atom,但没有任何变化。
这是我最近的尝试:
"*":
core:
customFileTypes:
"source.pro": [
"pro"
]
disabledPackages: [
"autocomplete-plus"
"markdown-preview"
"markdown-preview-plus"
"spell-check"
]
telemetryConsent: "limited"
themes: [
"atom-light-ui"
"one-light-syntax"
]
editor: {}
"exception-reporting":
userId: "283f523f-3348-4956-97f6-a73675e6e9c6"
"tree-view":
hideVcsIgnoredFiles: true
welcome:
showOnStartup: false
".basic.html.text":
editor:
tabLength: 4
".html.source":
editor:
tabLength: 4
".source.pro":
editor:
tabLength: 4
".shell.source":
editor:
tabLength: 4
".shtml.source":
editor:
tabLength: 4
我相当确定其中一些其他人也没有工作。在 Atom 中,如果我打开我的 .pro 文件并执行 Alt-Cmnd-P,它说文件类型是 text.plain.null-grammar
。制表符宽度仍然是 2 个字符。很明显我做错了什么。
您会注意到我正在尝试定义自定义文件类型(在顶部),然后定义制表符长度(在底部附近)。
看来,Atom 颠倒了 config.cson
中语言的作用域,因此与其使用 .source.pro
,不如使用 .pro.source
(与您的示例中的其他语言一样)。至少当您在包设置中为一种语言设置缩进时,它就是这样做的。
既然您提到您想与同事更好地相处:您是否考虑过使用与编辑器无关的 EditorConfig 标准来与他们共享缩进设置?每当您的项目包含 .editorconfig
文件时,这将覆盖您在不存在此类文件时将使用的个人首选项。 许多 编辑器直接或通过插件支持 EditorConfig。
您似乎需要为 .pro 文件安装语法,例如 language-qtpro
,否则 source.pro
作用域将不会激活。
(我相信这是因为 the fileTypes
field of a grammar package, which activates the scopeName
field。)