Julian Moreno
Julian Moreno

Reputation: 1104

Sublime Text 3 Default File Type on new file

I was looking around and the questions and answers did not seem to match what I am looking for (Sublime Text 3). Anytime I open a new file it defaults to a plain text file. I mostly work with PHP files so I was wondering if there is a setting that would be changed so that when I open a new file it will default to PHP.

I tried to find this directory path "Packages/Text/Plain_text.tmLanguage" here:

But I did not find the "tmLanguage" files.

Reference: Sublime Text 2 - Default Document Type

Upvotes: 5

Views: 8550

Answers (2)

Rowe Morehouse
Rowe Morehouse

Reputation: 4585

Rather than messing with the files in your OS and adding a .zip extension to one of them …

… if you want to find the directory path to a built-in .sublime-syntax or a .tmLanguage file install PacakgeResourceViewer from Package Control.

After installing, use command palette to Package Resource Viewer: Open Resource and find PHP.sublime-syntax.

You can then see the path is Packages/PHP/PHP.sublime-syntax.

then:

Install DefaultFileType and edit its configuration file: Packages/User/default_file_type.sublime-settings as follows:

{ "default_new_file_syntax": "Packages/PHP/PHP.sublime-syntax", "use_current_file_syntax": false }

Now your new files will default to sublime's built-in PHP syntax highlighting.

Upvotes: 0

schoenburg
schoenburg

Reputation: 21

The .tmLanguage files are within the .sublime-package files which are secretly simple archives holding all files necessary for a package to work.

Add a .zip extension to the .sublime-package file that contains the PHP settings and you can extract the .tmLanguage file you want as your new default.

Once you have that file, follow the instructions from the question you linked to and you should be good to go.

Set default file type in Sublime Text

Upvotes: 2

Related Questions