Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the default syntax highlighting for new files in Sublime Text [duplicate]

When I'm opening a new file (e.g. with Ctrl+N), the default Syntax in Sublime Text 3 is just Plain Text. I would like to change that into e.g. Markdown. (How) Is that possible?

I would like to avoid a "hacky" solution as proposed here:

creat a file in your Packages/User directory called 'default_syntax.py' or something, and add this:

import sublime, sublime_plugin

class DefaultSyntaxCommand(sublime_plugin.EventListener):
   def on_new(self, view):
      view.set_syntax_file('Packages/HTML/HTML.tmLanguage')
like image 494
andreas Avatar asked Oct 24 '16 16:10

andreas


People also ask

How do I change the syntax highlighting in Sublime Text?

The colors of the syntax highlighting depend on Sublime Text's color theme. You can change the theme by going to Preferences > Color Scheme.

Does Sublime Text support syntax highlighting?

Sublime Text can use both . sublime-syntax and . tmLanguage files for syntax highlighting.

Where does sublime save syntax?

You put your syntax definitions inside a package: Select Preferences > Browse Packages... this should open your file explorer. There you can either create a new folder for a new package or use the User folder, which is the default user package. Inside that create a file YourSyntax.

How do I change the file type in Sublime Text?

sublime-syntax goto the section file_extensions: and add your file extension sbt (like - sbt ) in the end of that section. Save and close the file and restart Sublime Text, you'll now have Scala syntax highlighting for your custom . sbt extension.


1 Answers

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": "Markdown/MultiMarkdown",

or

"new_file_syntax": "Markdown/Markdown",

depending on your installed Markdown syntax. Now if you open a new file, your default syntax will be Markdown.

like image 116
andreas Avatar answered Nov 15 '22 08:11

andreas