5

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:

  • C:\Program Files\Sublime Text 3\Packages
  • C:\Users\user\AppData\Roaming\Sublime Text 3\Packages

But I did not find the "tmLanguage" files.

Reference: Sublime Text 2 - Default Document Type

Community
  • 1
  • 1
Julian Moreno
  • 1,084
  • 3
  • 15
  • 30

2 Answers2

2

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

Community
  • 1
  • 1
schoenburg
  • 21
  • 2
  • I've extracted the "**.tmLanguage**" file, then I've created the "**default_file_type.sublime-settings**" file in "**C:\Users\user\AppData\Roaming\Sublime Text 3\Packages\User**" with the following configuration and it worked: `{ "default_new_file_syntax" : "Packages/Markdown/PHP.tmLanguage", "use_current_file_syntax" : false }` – Julian Moreno Jul 27 '15 at 19:05
  • Sorry, it works, but the first time that I pressed on "Ctrl+N" the system shows an annoying alert. I think it's not solved yet. – Julian Moreno Jul 27 '15 at 19:24
0

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.

Rowe Morehouse
  • 4,451
  • 3
  • 28
  • 28