reactjs - VS Code - 使用同一窗口打开文件并保留工作区

标签 reactjs visual-studio-code vscode-settings

我想要一种从终端打开/创建文件的方法 - 使用相同的 VS Code 窗口。
如果我尝试使用终端发出以下命令,它将关闭当前窗口并打开一个新窗口。

code . nameofthefile.js -r --reuse-window
然后,如果我正在运行 npm start - 上一个命令将杀死它。最重要的是 - 它将重新加载我的工作区,删除左侧栏中资源管理器中的所有文件夹。
如果我只使用..
code . nomeofthefile.js 
  • 这将打开一个新窗口。这也不是我想要的。

  • 是否可以在 VS Code 中使用终端命令在不关闭当前文件的情况下打开新文件?

    最佳答案

    VSCode 命令行 ( code ) 能够根据您提供的路径打开文件夹和文件。如果您提供多个路径,它将打开所有路径。如果路径不存在,它将在该位置为您创建一个新文件。

    # open current folder as workspace
    code .
    
    # open file.js in the last used workspace
    code file.js # or
    code -r file.js
    
    # open file.js inside current folder as workspace
    code . file.js
    
    因此,根据您提供的示例,您需要运行 code nameofthefile.js或者code -r nameofthefile.js (他们似乎都做同样的事情)不要覆盖您当前的工作区。

    关于reactjs - VS Code - 使用同一窗口打开文件并保留工作区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63416574/

    相关文章:

    javascript - 有什么方法可以将 immutable.js 与 lodash 一起使用?

    javascript - 功能组件的 setState 中的 prevState 到底是什么?

    reactjs - 创建 react 应用程序和元数据

    reactjs - Formik 组件未使用 react 选项卡渲染

    python - 模块未找到错误: No module named 'pandas' in vs code

    debugging - 在 VSCode 中使用 gdbserver 进行调试时停顿 - "The preLaunchTask ' docker gdb' 无法跟踪。”

    go - 如何修复 VS Code 错误 : "Not able to determine import path of current package by using cwd" for Go project

    visual-studio-code - VSCode - 灰色未使用的导入

    visual-studio-code - 如何将 VS-Code 选项卡设置从 "Change Focus"更改为 "Add Spaces"?

    visual-studio-code - 在 Visual Studio Code 中禁用 HTML 属性对齐