问题描述
之前 Sublime 过去默认将第一行作为文件名,但现在它是无标题".有没有办法启用它或有插件吗?
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?
谢谢
推荐答案
当语法设置为纯文本时,第一行仅用作未保存文件的文件名.只要您更改语法突出显示并键入内容,它就会将选项卡名称更改为无标题".
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".
此操作的实现位于默认包 set_unsaved_view_name.py
文件中.要使其适用于所有语法:
The implementation for this is in the Default package, set_unsaved_view_name.py
file. To get it to work for all syntaxes:
- 如果尚未安装 PackageResourceViewer,请通过 Package Control 安装
- 打开命令面板
- 输入
PRV:
并选择PackageResourceViewer: Open Resource
- 选择
默认
- 选择
set_unsaved_view_name.py
- Find
if syntax != 'Packages/Text/Plain text.tmLanguage':
- 从那里选择到
if
语句的结尾(第一个return
语句)(Python 是基于缩进的)包含return
为注释掉了. - 转到编辑菜单 -> 评论 -> 切换评论
- 保存文件
- 确保在您的首选项(用户、特定语法等)中,
set_unsaved_view_name
未设置为false
- 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) inclusivereturn
to be commented out. - 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
注意:这些说明在 ST 版本 3131 时有效,并且实现可能会在未来版本中发生变化.
Note: these instructions are valid as at ST build 3131, and the implementation could change in future builds.
这篇关于如何在保存时启用 sublime text 以第一行作为文件名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!