问题
Earlier the Sublime used to take first line as file name by default but now it's "untitled". Is there a way to enable it or is there a plugin for that?
Thanks
回答1:
The first line is only used as the file name for unsaved files when the syntax is set to Plain Text. As soon as you change the syntax highlighting and type something, it will change the tab name to "untitled".
The implementation for this is in the Default package, set_unsaved_view_name.py
file. To get it to work for all syntaxes:
- Install PackageResourceViewer through Package Control if it is not already installed
- Open Command Palette
- Type
PRV:
and selectPackageResourceViewer: Open Resource
- Select
Default
- Select
set_unsaved_view_name.py
- Find
if syntax != 'Packages/Text/Plain text.tmLanguage':
- Select from there to the end of the
if
statement (the firstreturn
statement) (Python is indentation based) inclusive - Go to the Edit menu -> Comment -> Toggle Comment
- Save the file
- Ensure that, in your preferences (user, syntax specific etc.),
set_unsaved_view_name
is not set tofalse
Note: these instructions are valid as at ST build 3131, and the implementation could change in future builds.
来源:https://stackoverflow.com/questions/43781845/how-to-enable-sublime-text-to-take-first-line-as-file-name-while-saving