8

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

pertrai1
  • 4,146
  • 11
  • 46
  • 71
  • 1
    try http://stackoverflow.com/questions/7574502/set-default-syntax-to-different-filetype-in-sublime-text-2, you can also double click on the lower right hand corner while in an html file and choose the "Open all with current extension as..." and set it to HTML – jeremy Aug 05 '12 at 06:51
  • I rcommend you to see this post. http://stackoverflow.com/questions/9520540/sublime-text-2-default-document-type – thanksnote Aug 05 '12 at 06:51
  • Nile, this helped me find what I needed. Just need your answer to be one that I can accept? – pertrai1 Aug 06 '12 at 12:36
  • You can start working on Adobe Dreamweaver. I think you are asking about the Default HTML whenever you start writing the code for new HTML file. – Ankit Aggarwal Aug 13 '13 at 08:04

3 Answers3

7

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')
CrazyTim
  • 6,695
  • 6
  • 34
  • 55
Jaykul
  • 15,370
  • 8
  • 61
  • 70
  • After this all files I open are `PowershellSyntax`. Also all files with another file extension. Before, files with a file extension opened in the "right" file syntax. – caramba May 12 '17 at 13:18
  • It should only affect _new_ files. – Jaykul May 24 '17 at 05:49
1

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

which will automatically sets the syntax for new files.

aisin
  • 1,107
  • 7
  • 11
  • 2
    Problem. This only works if you do Ctrl+N/Cmd+N. This package does not work if you typically create new files by double clicking in tab area. – hubbardr Aug 11 '14 at 23:12
1

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.

andreas
  • 16,357
  • 12
  • 72
  • 76