如何在保存时启用 sublime text 以第一行作为文件名? [英] How to enable sublime text to take first line as file name while saving?

查看:97
本文介绍了如何在保存时启用 sublime text 以第一行作为文件名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

之前 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:

  1. 如果尚未安装 PackageResourceViewer,请通过 Package Control 安装
  2. 打开命令面板
  3. 输入 PRV: 并选择 PackageResourceViewer: Open Resource
  4. 选择默认
  5. 选择set_unsaved_view_name.py
  6. Find if syntax != 'Packages/Text/Plain text.tmLanguage':
  7. 从那里选择到 if 语句的结尾(第一个 return 语句)(Python 是基于缩进的)包含 return 为注释掉了.
  8. 转到编辑菜单 -> 评论 -> 切换评论
  9. 保存文件
  10. 确保在您的首选项(用户、特定语法等)中,set_unsaved_view_name 未设置为 false
  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 return to be commented out.
  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

注意:这些说明在 ST 版本 3131 时有效,并且实现可能会在未来版本中发生变化.

Note: these instructions are valid as at ST build 3131, and the implementation could change in future builds.

这篇关于如何在保存时启用 sublime text 以第一行作为文件名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆