简体   繁体   English

Sublime 3-文件->打开文件夹和项目->打开项目之间的区别

[英]Sublime 3 - Difference Between File -> Open Folder and Project -> Open Project

I have been using Sublime 3 almost 2 years. 我已经使用Sublime 3差不多2年了。 When I want to work with what I did was File -> Open Folder . 当我想使用所做的工作时,选择File -> Open Folder

But there is a option for Project -> Open Project . 但是Project -> Open Project有一个选项。

So what is the difference between both of them? 那么两者之间有什么区别? What are the advantages and disadvantages of both methods. 两种方法的优缺点是什么?

TL;DR: The main difference is persistence of your working environment, if that matters to you. TL; DR: 主要区别是您的工作环境的持久性(如果您认为很重要)。

When you select File > Open Folder and pick a folder, that folder and it's contents are added to the side bar as open folders in the current window, subject to various settings that tell Sublime what files to ignore or exclude. 当选择“ File > Open Folder并选择一个文件夹时,该文件夹及其内容将作为当前文件夹在当前窗口中添加到侧栏中,这取决于告诉Sublime忽略或排除哪些文件的各种设置。 Various functionality in Sublime Text is based on the files available in open folders. Sublime Text中的各种功能基于打开的文件夹中可用的文件。

Examples include Go To Anything allowing you to select from a list of all files found or the symbols from all of the found files being put into the global symbol list, which powers Goto Symbol and Goto Definition . 例如,“ Go To Anything使您可以从所有找到的文件的列表中进行选择,或者从所有找到的文件中放入全局符号列表的符号中进行选择,这将为Goto SymbolGoto Definition动力。

Sublime contains a setting named hot_exit , which is turned on by default. Sublime包含一个名为hot_exit的设置,该设置默认情况下处于启用状态。 When this setting is turned on, the state of Sublime at the time you quit it is stored in a session file and then restored the next time you start Sublime. 启用此设置后,退出时的Sublime状态将存储在会话文件中,然后在下次启动Sublime时恢复。

The session stores things like the layout of the window or windows that were open when Sublime was terminated, the list of files that were open, their position, the cursor locations, selected text and unsaved changes along with a lot of other bits and pieces. 会话存储诸如Sublime终止时打开的一个或多个窗口的布局,打开的文件列表,它们的位置,光标位置,选定的文本和未保存的更改以及许多其他细节的信息。

So, if you're using File > Open Folder and you work for a while, then you quit Sublime and come back later, everything is restored exactly as it was when you quit, and you can continue working. 因此,如果您使用“ File > Open Folder并且工作了一段时间,则退出Sublime并稍后再返回,所有内容将完全按照退出时的状态还原,您可以继续工作。

The session information that's stored for files that you open this way is transient; 对于以这种方式打开的文件,存储的会话信息是暂时的。 it's only persisted while the window is open. 仅在窗口打开时才保留。 If you close that window while Sublime is running, the next time you select File > Open Folder again, you can see the file structure in the side bar (if visible), but the list of files that you had open and all of that other information I mentioned above is reset, so it's like starting over. 如果在Sublime运行时关闭该窗口,则下次再次选择“ File > Open Folder时,您会在侧栏中看到文件结构(如果可见),但是会看到已打开的文件以及所有其他文件的列表。我上面提到的信息已重置,因此就像从头开始。

If instead after opening folders you select Project > Save Project As... , you're creating a sublime-project file which directly contains the list of folders that you opened, and that file is persisted to disk somewhere in a file of your choosing. 相反,如果在打开文件夹后选择“ Project > Save Project As... ,那么您正在创建一个sublime-project文件,该文件直接包含您打开的文件夹列表,并且该文件会持久保存到您选择的文件中的某个位置。 This can be inside of one of the folders you opened or some other location. 它可以在您打开的文件夹之一或其他位置。

In the project file (use Project > Edit Project to open it) you can specify settings that apply only to files opened in the window where the file is open; 在项目文件中(使用“ Project > Edit Project将其打开),您可以指定仅适用于在打开文件的窗口中打开的文件的设置。 for example you could change the tab_size to something different than what you normally use just for files in that project. 例如,您可以将tab_size更改为不同于通常仅用于该项目中文件的内容。 The Project file can also contain build systems that apply only to that project. 项目文件还可以包含仅适用于该项目的构建系统。

When you save a project you're also saving a sublime-workspace file (and you can have several sublime-workspace files for a project if you want to, see Project > Save Workspace as... ). 保存项目时,还保存了一个sublime-workspace文件(如果需要,您可以为一个项目提供多个sublime-workspace文件,请参阅Project > Save Workspace as... )。 The work space file is basically a mini session file that applies to that project. 工作空间文件基本上是适用于该项目的小型会话文件。

When you close a window that has a project loaded in it, the state of everything is persisted into the workspace file and restored the next time you use that project. 当您关闭其中装有项目的窗口时,所有内容的状态都将保留在工作区文件中,并在下次使用该项目时恢复。 This means that when you open a project, the window you see is the same window that you had the last time you used the project; 这意味着,当您打开一个项目时,看到的窗口与上次使用该项目的窗口相同。 the files you had open are still open, the cursor locations are saved, and so on. 您打开的文件仍处于打开状态,光标位置已保存,依此类推。

Where this really shines is in combination with the Project > Quick Switch Project menu entry or it's associated key binding (note: there is no default key binding for this on Windows, requiring you to make your own). 与“ Project > Quick Switch Project菜单项或其关联的键绑定结合使用时,真正令人眼前一亮的地方(请注意:Windows上没有默认的键绑定,需要您自行创建)。

This command opens a panel with all projects and work spaces that you've created so that you can quickly filter down and select a project that you've used before. 该命令将打开一个面板,其中包含您创建的所有项目和工作空间,以便您可以快速筛选并选择之前使用的项目。 The result is an immediate swap of content of the current window to the item selected. 结果是将当前窗口的内容立即交换为所选项目。

This level of persistence is a time saver and productivity booster if you happen to be often working with the same sets of files in the same way. 如果您碰巧经常以相同的方式处理相同的文件集,则这种持久性级别可以节省时间并提高工作效率。

When you open a Project, that project is added to the root folder of the Sublime 3. Which means you have a current root project Running and you add another project to that. 当您打开一个项目时,该项目将被添加到Sublime 3的根文件夹中。这意味着您当前有一个正在运行的根项目,并向其中添加了另一个项目。 When you open a file, you open a new file folder which is not added to the Current Root project. 当您打开文件时,您将打开一个新的文件夹,该文件夹不会添加到“当前根”项目中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM