Sublime Forum

Autoset tab name for new (unsaved) files for custom syntax

#1

If I start a new (unsaved) text file, the tab name is automatically set from the first line of text.
But if I change the file to a different syntax, this feature doesn’t work – the tab says “untitled” until there’s a filename.

I want files using my custom syntax to set the tab name – same as default behavior for text files. How can I do this?

thx!
-z

0 Likes

#2
1 Like

#3

Perfect. Thanks @kingkeith.
Any hints on where to find the magic set_unsaved_view_name.py file?
Cheers

0 Likes

#4
  1. install PackageResourceViewer
  2. open Command Palette
  3. Type PRV: O
  4. Select PackageResourceViewer: Open Resource
  5. Default
  6. set_unsaved_view_name.py
3 Likes

#5

@kingkeith perfect. thx.

0 Likes

#6

For anyone else who might need this info, I was able to resolve this by altering a single line in the set_unsaved_view_name.py file:

if syntax != 'Packages/Text/Plain text.tmLanguage':

changed to:

if syntax != 'Packages/Text/Plain text.tmLanguage' and syntax != 'Packages/User/myCustom.sublime-syntax':`

Adding other syntaxes the same way (using the and operator) will add the auto_name functionality to them as well.

0 Likes