Sublime Forum

Opening new file in HTML instad of Plain Text

#1

Hi,
I have a question I have Sublime Text 3, every time I open a new file it opens with Plain Text, I have to manually change it to HTML, does any one know how I can get it to open in HTML automatically ?

0 Likes

Default HTML Style when opening
#2

Yes, this is possible. Put the following file inside the Packages/User directory. It must be named Main.sublime-menu.

// Packages/User/Main.sublime-menu
[
  {
    "caption": "File",
    "id": "file",
    "children":
    [
      { 
        "caption": "New HTML File",
        "command": "new_file",
        "args": { "syntax": "Packages/HTML/HTML.sublime-syntax" }
      }
    ]
  }
]

You should see this in your File menu:

0 Likes

#3

I don’t think this is the best solution. If I understand the question correctly, the intention is more “How make HTML the default syntax for any new file”… So when Sublime starts, the very first file has HTML syntax by default, not plain text.

Adding a menu item still means you need to click “New HTML File” each time opening Sublime Text…

Is that possible?

0 Likes

#4

Yes. https://facelessuser.github.io/ApplySyntax/usage/#new-file-syntax

And it’s actually quite simple to write one with ST plugin API if ApplySyntax is too bloat for you.

0 Likes

#5

It doesn’t have to be necessarily a menu item. Since new_file is a built in command, you can also use a custom keybinding to make it even faster to open a file with HTML syntax applied to it.

0 Likes