Sublime Forum

Revert syntax to whatever ST would choose?


Hello All –

I searched around, but didn’t see an answer to this: I’m developing a plugin with a syntax definition, and I’m using view.set_syntax_file to set the syntax via a command – But I’d like the ability to then toggle back to whatever syntax Sublime Text would choose by default… Is there any way to do this? I tried view.set_syntax_file(None) and view.set_syntax_file("") to no avail…




Sublime Text only detects the syntax in specific conditions: pasting into an empty file, opening a file, etc. You can either revert back to the previous syntax by making a copy of the "syntax" setting of the view and setting it back to that, or by using sublime.find_syntax to re-detect the syntax.



Thanks @bschaaf!

It looks like sublime.find_syntax is too new – in build 4050, which isn’t out yet? And I’m probably the last to know, but it looks like there’ll be a ST4? I can’t seem to find any news about it tho…? But that’s exciting!

Anyway, I see now how I can get the current syntax (view.settings().get("syntax")) and cache it (view.settings().set("key", "value")) to restore it later – That’ll work for now, thanks!!



If you own a license you can get the latest private ST4 build from our discord server.

1 Like


rad, thx :+1:



API Tracker

1 Like