问题描述
在 Sublime Text 2 中,我已经看到了基于扩展的语法的方法.但是没有扩展名的文件名呢?例如,我经常有一个名为Vagrantfile"的文件,它是 ruby,但 Sublime Text 2 总是想以纯文本开始.如果文件名为Vagrantfile",有没有办法让它默认为ruby"?
In Sublime Text 2, I've seen ways of basing the syntax off of the extension. But what about a filename with no extension? For example, I often have a file called "Vagrantfile" which is in ruby, yet Sublime Text 2 always wants to start off in plain text. Is there a way to have it default to "ruby" for a file if it is called "Vagrantfile"?
推荐答案
使用 Sublime Text 2.0.1, build 2217,查看窗口的右下角,它为打开的 Vagrantfile 显示纯文本".
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.
点击它,在打开的菜单中,在顶部,将有一个以当前扩展名打开所有..."子菜单.进入该子菜单并选择 Ruby.
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.
即使 Vagrantfile 没有扩展名,Sublime 也会记住这一点并按预期使用 Ruby 语法打开 Vagrantfiles.这不会传播到所有没有扩展名的文件.
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.
这篇关于根据文件名更改默认语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!