Notepad++ 在 Visual Studio 代码中保存会话等效项?

Notepad++ Save Session equivalent in Visual Studio Code?

在Notepad++中有一个名为'Save session'的选项可以保存所有打开文件的列表(在当前window)、书签、代码折叠、光标位置等,所以我可以即使我关闭文件,稍后也会重新打开该状态。

在Visual Studio代码中,我没有找到这样的选项。工作区似乎只保存文件夹路径和定义到该工作区的一些设置。

有没有办法在 Visual Studio 代码中创建类似 Notepadd++ 会话的东西?

我认为与您要求的最相似的是Workspaces。从测试来看,他们实际上会保留您打开的文件,只要您先关闭菜单中的工作区。

A Visual Studio Code "workspace" is the collection of one or more folders that are opened in a VS Code window (instance). In most cases, you will have a single folder opened as the workspace but, depending on your development workflow, you can include more than one folder, using an advanced configuration called Multi-root workspaces.

The concept of a workspace enables VS Code to:

  • Configure settings that only apply to a specific folder or folders but not others.
  • Persist task and debugger launch configurations that are only valid in the context of that workspace.
  • Store and restore UI state associated with that workspace (for example, the files that are opened).
  • Selectively enable or disable extensions only for that workspace.

如果您在“文件”下查看,您会看到“工作区”选项:

它的工作方式是保存一个 .code-workspace 扩展名的文件,但实际上底层结构是 JSON。例如,该文件可能如下所示:

{
    "folders": [
        {
            "path": "..\..\..\..\dev\Project Files\Project\MyProject"
        }
    ],
    "settings": {}
}