简体   繁体   English

在 VS Code 启动时.. 自动连接到 WSL-Ubuntu,打开项目文件夹和个人文件

[英]On VS Code startup.. Connect automatically to WSL-Ubuntu, open project folders, and personal files

Earlier days.. My requirement: As soon as I open the VS Code, open these two together: a.早些时候..我的要求:打开VS Code后,将这两个一起打开:a。 project folder(s) - development related b.项目文件夹 - 与开发相关的 b. my personal text files like Notes.txt lying in some other folders我的个人文本文件(例如 Notes.txt)位于其他一些文件夹中

Answer: Create a workspace Add folder (my development project) to workspace Open the personal text files Save workspace Next time on VS Code startup.. Just open this workspace答案:创建一个工作空间 将文件夹(我的开发项目)添加到工作空间 打开个人文本文件 保存工作空间 下次在 VS Code 启动时.. 只需打开这个工作空间

Nowadays.. My requirement: As soon as I open the VS Code (on startup), do these: a.如今..我的要求:一旦我打开 VS Code(在启动时),请执行以下操作: Connect automatically to WSL-Ubuntu b.自动连接到 WSL-Ubuntu b。 Open the remote project folder(s) c.打开远程项目文件夹 c。 Open my personal text files打开我的个人文本文件

ie everything in a single VS Code instance.即单个 VS Code 实例中的所有内容。

I tried out several ways but of no avail.我尝试了几种方法,但无济于事。 The main limitation is when I click the 'Remote Connect' manually, it opens a new VS Code instance which I don't want.主要限制是当我手动单击“远程连接”时,它会打开一个我不想要的新 VS Code 实例。

Pl. PL。 guide how to achieve this.指导如何实现这一目标。

VS-Code can be run in two environments: VS-Code 可以在两种环境中运行:

a.一个。 Local: The VS Code is run in the Windows local environment.本地:VS Code 在 Windows 本地环境中运行。 Open the files and folders using the path like D:\Project\business\Notes.txt使用 D:\Project\business\Notes.txt 等路径打开文件和文件夹

b.湾。 Remote: The VS Code is run in the WSL Ubuntu environment.远程:VS Code 在 WSL Ubuntu 环境中运行。 Open the files and folders using the path like /mnt/d/Project/business/Notes.txt使用 /mnt/d/Project/business/Notes.txt 等路径打开文件和文件夹

Suppose that you have a file, already opened in the VS Code, whose path is D:\Project\business\Notes.txt.假设你有一个文件,已经在 VS Code 中打开,它的路径是 D:\Project\business\Notes.txt。 This means that it is a 'local' environment.这意味着它是一个“本地”环境。

Now if you open another file using this path, /mnt/d/Project/business/api/main.ts, the VS Code will not open it in the same 'local' (existing VS Code instance) environment.现在,如果您使用此路径 /mnt/d/Project/business/api/main.ts 打开另一个文件,VS Code 将不会在相同的“本地”(现有 VS Code 实例)环境中打开它。 Instead it starts another 'remote' VS Code instance and opens this file over there.相反,它会启动另一个“远程”VS Code 实例并在那里打开这个文件。 It is because /mnt/d means that you want to open the Windows D drive in the 'remote' environment.这是因为 /mnt/d 表示你要在'远程'环境中打开 Windows D 驱动器。

Inn other words, it means.. if you are working in a 'remote' environment, do not open the files and folders using the standard Windows path.换句话说,这意味着.. 如果您在“远程”环境中工作,请不要使用标准 Windows 路径打开文件和文件夹。 Otherwise, a new VS window will be opened for you.否则,将为您打开一个新的 VS window。

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

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