50

在 Sublime Text 2 中,我看到了基于扩展的语法的方法。但是没有扩展名的文件名呢?例如,我经常有一个名为“Vagrantfile”的文件,它是 ruby​​ 格式的,但 Sublime Text 2 总是希望以纯文本开始。如果文件名为“Vagrantfile”,有没有办法让它默认为“ruby”?

4

2 回答 2

114

With Sublime Text 2.0.1, build 2217, look in the lower right of the window, where it says "Plain Text" for the Vagrantfile that is open.

enter image description here

Click that and in the menu that opens, at the top, there will be an "Open all with current extension as ..." sub-menu. Go into that sub-menu and choose Ruby.

Even though the Vagrantfile has no extension, Sublime will remember this and open Vagrantfiles with the Ruby syntax as expected. This does not spread to all files with no extension.

于 2012-09-02T22:29:31.077 回答
14

将以下行添加到语法特定 - 用户文件中

首选项 > 设置 - 更多 > 特定语法 - 用户

永久保留每个 Vagrantfile 文件的语法。


{
    "extensions":
    [
        "Vagrantfile"
    ]
}
于 2014-04-02T11:14:04.523 回答