简体   繁体   English

如何在 Visual Studio Code (VSC) 中打开多个文件?

[英]How can multiple files be opened in Visual Studio Code (VSC)?

How can multiple files be opened in Visual Studio Code (VSC)?如何在 Visual Studio Code (VSC) 中打开多个文件?

For some reason, my copy of Visual Studio Code can only open one file at a time.出于某种原因,我的 Visual Studio Code 副本一次只能打开一个文件。 For example, if there are two files in the workspace folder, let's say an HTML and CSS file, both cannot be opened simultaneously.例如,如果工作区文件夹中有两个文件,比方说一个 HTML 和 CSS 文件,这两个文件不能同时打开。 If one file is open, clicking any other item in VSC's file explorer will replace the current file.如果打开一个文件,单击 VSC 文件资源管理器中的任何其他项目将替换当前文件。 VSC will not open the other file in a new editing tab. VSC 不会在新的编辑选项卡中打开其他文件。

I am not concerned with running multiple instances, Workspaces or folders of VSC.我不关心运行 VSC 的多个实例、工作区或文件夹。 I just want to open two files in the same folder.我只想在同一个文件夹中打开两个文件。 Is there a configuration setting controlling this?是否有控制这个的配置设置? Or is this the result of upgrading to the latest version of VSC?或者这是升级到最新版本的 VSC 的结果? Is just a "new feature" of VSC?只是VSC的“新功能”吗?

It's seems ridiculously simple, but I need help.这看起来简单得可笑,但我需要帮助。 I am running Visual Studio Code v. 1.24.0 for Windows 10 64 bit.我正在为Windows 10 64 位运行 Visual Studio Code v.1.24.0。

Visual Studio Code screenshot: Visual Studio 代码截图:

在此处输入图像描述

In VS Code, if you click once on a file, it opens it in a temporary tab.在 VS Code 中,如果您单击一个文件,它会在一个临时选项卡中打开它。 This is helpful if you are looking into a bunch of files searching for something, without opening every single one of them.如果您正在查看一堆文件以搜索某些内容,而无需打开每个文件,这将很有帮助。

If you want to open a file in a new tab that persists until closed manually, double click on the file.如果要在新选项卡中打开一个文件,该选项卡会一直持续到手动关闭,请双击该文件。

You can also persist a tab that was previously created as a temporary tab by double clicking on the tab.您还可以通过双击选项卡保留以前作为临时选项卡创建的选项卡。 Note that temporary tabs have a cursive title, while normal tabs do not.请注意,临时标签有一个草书标题,而普通标签没有。

Others have mentioned double-clicking the file in order to open it, however, I will suggest an alternative approach:其他人提到双击文件以打开它,但是,我会建议另一种方法:

Within your settings, under workbench, set:在您的设置中,在工作台下,设置:

"workbench.editor.enablePreview": false
"workbench.editor.enablePreviewFromQuickOpen": false,

This will allow you to open the files with a single click, as opposed to double-clicking.这将允许您单击打开文件,而不是双击。 It may seem minute, but it was incredibly annoying to have to double-click every single file.这可能看起来很微小,但不得不双击每个文件实在是太烦人了。

VS Code, by default, keep this option enabled to open a file in a temporary file, this feature comes in handy when you want to just take a look at some code. VS Code 默认情况下,启用此选项以在临时文件中打开文件,当您只想查看一些代码时,此功能会派上用场。

If you want to open a file in a new tab, just double click on the tab or double click on the folder you want to open from explorer or once the file is opened press the short-cut key ctrl + k + enter .如果要在新选项卡中打开文件,只需双击该选项卡或双击要从资源管理器打开的文件夹,或者在打开文件后ctrl + k + enter


You can even disable this option in File > Preferences > Settings , under the user settings.您甚至可以在用户设置下的File > Preferences > Settings禁用此选项。

Paste this code in your user's setting.将此代码粘贴到您的用户设置中。

"workbench.editor.showTabs": false

Please follow below steps:-请按照以下步骤操作:-

File > Preferences > Settings .文件 > 首选项 > 设置 Now you will see USER SETTINGS and WORKSPACE SETTINGS.现在您将看到用户设置和工作区设置。

Click on WORKSPACE SETTINGS .单击工作区设置 Now search for workbench.editor.showTabs and change it's value to true .现在搜索workbench.editor.showTabs并将其值更改为true

I tested this by turning it false and it restricts from opening multiple files in tabs.我通过将其设置为 false 并限制在选项卡中打开多个文件来对此进行测试。 When it's false whenever you open one file only that file will be opened and the earlier file gets closed.每当您打开一个文件时它为 false 时,只会打开该文件并关闭较早的文件。

When set to true, you can open as many files you want and all files will be a new tab.设置为 true 时,您可以打开任意数量的文件,所有文件都将是一个新选项卡。

Go to 'settings' in VSCode and search for 'preview' then on the 2nd position from the top you will find " Workbench › Editor: Enable Preview " simply untick it and your problem will be solved.转到 VSCode 中的“设置”并搜索“预览”,然后在顶部的第二个位置找到“工作台 › 编辑器:启用预览”,只需取消选中它,您的问题就会得到解决。

In this GIF you can see it's working properly.在此GIF 中,您可以看到它运行正常。

VS Code ,打开设置,搜索“showTabs”并选中或启用复选框。

If you ctrl+click or shift+click and highlight all the files in the sidebar, then you can click and drag them all to whatever area of the editor you want.如果您 ctrl+click 或 shift+click 并突出显示侧栏中的所有文件,那么您可以单击并将它们全部拖动到您想要的编辑器的任何区域。 vscode打开多个文件

只需双击文件即可在新选项卡中打开

Double click on the file and it will be opened permanently in the visual studio window until closed manually.双击该文件,它将在 Visual Studio 窗口中永久打开,直到手动关闭。 If you single click on the file, then the file can be replaceable if some other file is opened.如果单击该文件,则可以在打开其他文件时替换该文件。

Short Answer : 1. Double click on the file.简答: 1. 双击文件。 (OR) 2. ctrl + k + enter and single click on the file. (或) 2. ctrl + k + enter 并单击文件。

Try the 3 dots on the upper right hand side corner,right beside the icon for splitting the the editor.试试右上角的 3 个点,就在用于拆分编辑器的图标旁边。 From the drop down check if the option keep editors open is enabled.If not enable it.从下拉列表中检查是否启用了保持编辑器打开的选项。如果没有启用它。

在文件资源管理器上打开文件并使用 Visual Studio 代码打开。

You can use VS Code with the extension "vscode-arduino".您可以使用扩展名为“vscode-arduino”的 VS Code。 It will allow you to manage multiple .ino files as Tabs as in the Arduino IDE does.它将允许您像在 Arduino IDE 中一样管理多个 .ino 文件作为选项卡。 Plus the advantages of intellisense.加上智能感知的优势。

Set up Arduino System设置Arduino系统

We need to change a few system settings before we can start programming.在开始编程之前,我们需要更改一些系统设置。 All of these can be accessed via VS Code's interface.所有这些都可以通过 VS Code 的界面访问。

Once you have opened up an Arduino .ino file, VS Code reconfigures in an Arduino mode, and gives access to special functionality in its bottom blue margin.打开 Arduino .ino 文件后,VS Code 将重新配置为 Arduino 模式,并在其底部蓝色边距中提供特殊功能的访问权限。

  1. Click on and select AVR ISP (Arduino AVR Board)单击并选择 AVR ISP (Arduino AVR Board)

  2. Click on and select Arduino/Genuino Uno单击并选择 Arduino/Genuino Uno

To set the serial port that VS Code will communicate with your Arduino Uno we need to open up the Command Palette (Cntrl+Shift+p) and then type “Arduino Select Serial Port”.要设置 VS Code 将与您的 Arduino Uno 通信的串行端口,我们需要打开命令面板(Cntrl+Shift+p),然后键入“Arduino Select Serial Port”。 You should then select which USB port your Uno is connected to.然后您应该选择您的 Uno 连接到哪个 USB 端口。

You can access the Serial Monitor by clicking on the plug symbol on the blue line您可以通过单击蓝线上的插头符号来访问串行监视器

This extension includes a package manager, which makes external package installation really easy.这个扩展包括一个包管理器,这使得外部包安装非常容易。 Open up the command palette and type “Arduino package manager”.打开命令面板并输入“Arduino package manager”。 A new tab should appear that features many packages to install just by clicking on a button.应该会出现一个新选项卡,其中包含许多只需单击按钮即可安装的软件包。

Verify and Upload Your Code验证并上传您的代码

VS Code in Arduino mode provides a couple of convenient icons for you to click for code verification and uploading to your connected Arduino board. Arduino 模式下的 VS Code 提供了几个方便的图标供您单击以进行代码验证并上传到您连接的 Arduino 板。 These are available in the upper right-hand corner.这些可以在右上角找到。 Either operation will result in a console window appearing at the bottom of VS Code informing you of the outcome.任一操作都会在 VS Code 底部出现一个控制台窗口,通知您结果。

在此处输入图片说明

Checkout the Maker.pro website for a complete how to tutorial查看 Maker.pro 网站以获取完整的教程

https://maker.pro/arduino/tutorial/how-to-use-visual-studio-code-for-arduino https://maker.pro/arduino/tutorial/how-to-use-visual-studio-code-for-arduino

PS: don't forget to enable multiple tabs on VS code settings PS:不要忘记在 VS 代码设置上启用多个选项卡

File > Preferences > User > Workbench > Editor Management文件 > 首选项 > 用户 > 工作台 > 编辑器管理

go to Setting--> type in the search box 'json'--> under 'Launch' click on "edit in setting json" then make the workbench.editor from false to true showing below.转到设置-> 在搜索框中键入“json”-> 在“启动”下单击“在设置 json 中编辑”,然后将 workbench.editor 从 false 变为 true,如下所示。

"workbench.editor.showTabs": true, "workbench.editor.enablePreview": true “workbench.editor.showTabs”:真,“workbench.editor.enablePreview”:真

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

相关问题 如何删除最近在 Visual Studio Code 上打开的文件会话? - How to delete recent opened file session on Visual Studio Code? 如何在类似 Unix 的 Visual Studio Code 中的所有文件中制作所有行结尾 (EOL)? - How can I make all line endings (EOLs) in all files in Visual Studio Code, Unix-like? 如何关闭从visual studio中打开的“孤立”控制台窗口? - How to close an “orphaned” console window that was opened from within visual studio? 如何在 visual studio code 上运行 yarn cammand? - How can run yarn cammand on visual studio code? 如何使用葡萄牙语打印到 Visual Studio Code 控制台? - How can I print to the Visual Studio Code console in Portuguese? 在代码管理菜单中恢复visual studio code中删除的文件 - Restore deleted files in visual studio code in the code management menu 如何在 Visual Studio 中从多个 c 源文件和 header 文件创建 .dll 或 .lib? - How to create .dll or .lib from multiple c source and header files in visual studio? 如何在 Visual Studio Code 中调试 Lua - How to Debug Lua in Visual Studio Code 如何在 Visual Studio 代码中抑制额外的 output? - How to suppress the extra output in visual studio code? 我如何打开Visual Studio这样的应用程序,以便我可以运行代码? - How to i open this applications is visual studio so i can run the code?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM