Sublime Forum

default_syntax setting ignored for new files; requires set_timeout workaround in plugin

#1

Description

I am attempting to configure Sublime Text 4 so that all new, unsaved files (created via Cmd+N) automatically default to Markdown syntax.

However, the documented default_syntax setting in Preferences.sublime-settings is ignored. Additionally, writing a standard EventListener hook on on_new fails unless a manual timeout delay is added, suggesting that Sublime Text is internally overwriting the syntax immediately after the view is created.

Steps to reproduce

  1. Open Preferences.sublime-settings.
  2. Add the following line:
    "default_syntax": "Packages/Markdown/Markdown.sublime-syntax"
    
  3. Restart Sublime Text.
  4. Create a new file (Cmd+N).
  5. Check the syntax of the new file (bottom right corner or via console).

Expected behavior

The new file should have the syntax set to Markdown.

Actual behavior

The new file defaults to Plain Text.

Environment

  • OS: macOS
  • Sublime Text Version: Build 4200

Additional Information / Workaround

Existing plugins (like “Default File Type”) also fail to trigger reliably.

I was able to get this working only by creating a custom plugin with a manual delay. This indicates a race condition where ST4 processes internal default syntax logic after the on_new event fires, overwriting any immediate changes.

The working workaround:

User/default_markdown.py:

import sublime
import sublime_plugin

class DefaultMarkdownListener(sublime_plugin.EventListener):
    def on_new(self, view):
        # A delay is required. Without set_timeout, the syntax assignment 
        # is immediately overwritten by internal ST processing.
        sublime.set_timeout(lambda: view.assign_syntax("Packages/Markdown/Markdown.sublime-syntax"), 100)
0 Likes

#2

Are you sure that your preferences file doesn’t have some form of override on it? As of build 4200, there is no such setting documented in the default settings.

0 Likes