How to enable sublime text to take first line as file name while saving?

自古美人都是妖i 提交于 2019-12-10 10:33:33

问题


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:

  1. Install PackageResourceViewer through Package Control if it is not already installed
  2. Open Command Palette
  3. Type PRV: and select PackageResourceViewer: Open Resource
  4. Select Default
  5. Select set_unsaved_view_name.py
  6. Find if syntax != 'Packages/Text/Plain text.tmLanguage':
  7. Select from there to the end of the if statement (the first return statement) (Python is indentation based) inclusive
  8. Go to the Edit menu -> Comment -> Toggle Comment
  9. Save the file
  10. Ensure that, in your preferences (user, syntax specific etc.), set_unsaved_view_name is not set to false

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!