Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sublime Text 2 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. Anytime I open a new file it defaults to a plan text file. I mostly work with HTML 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 HTML? Hope this is possible.

Rob

like image 916
pertrai1 Avatar asked Aug 05 '12 06:08

pertrai1


3 Answers

Create a new plugin Tools > Developer > New Plugin...

Paste this in:

import sublime, sublime_plugin

class EverythingIsPowerShell(sublime_plugin.EventListener):
   def on_new(self, view):
      view.set_syntax_file('Packages/PowerShell/Support/PowershellSyntax.tmLanguage')

Save and call it NewTabSyntax.py. New tabs will now default to Powershell.

You can change the syntax to whatever you prefer. To find out the "path" of a particular syntax, simply open a file of that syntax, open the console (View > Show Console) and type:

view.settings().get('syntax')
like image 123
Jaykul Avatar answered Nov 18 '22 23:11

Jaykul


pls install Package sublime-DefaultFileType https://github.com/spadgos/sublime-DefaultFileType

which will automatically sets the syntax for new files.

like image 29
aisin Avatar answered Nov 18 '22 23:11

aisin


It is possible with the ApplySyntax Plugin. Once it is installed (e.g. via PackageControl), you can set the ApplySyntax User Settings like that:

"new_file_syntax": "HTML",

Now if you open a new file, your default syntax will be HTML. Of course you can set every Syntax you have installed.

like image 41
andreas Avatar answered Nov 18 '22 22:11

andreas