简体   繁体   English

如何从 PowerShell 控制台中使用 Visual Studio Code 打开文件?

[英]How to open a file with Visual Studio Code from within a PowerShell console?

I try to open a file in Visual Studio Code from within a PowerShell console.我尝试从 PowerShell 控制台中打开 Visual Studio Code 中的文件。 In other words I want to emulate the option of Open with when right clicking a file to open it with the non-default application, but from the PowerShell command line.换句话说,我想在右键单击文件以使用非默认应用程序打开它时模拟Open with选项,但来自 PowerShell 命令行。 I found a Stack Overflow question with this solution:我用这个解决方案发现了一个 Stack Overflow 问题:

Visual studio code D:\testfolder\index.html

But it does not work.但它不起作用。 Are there any ideas on how to solve it?关于如何解决它有什么想法吗?

you can also use -n flag if you have an existing vs code window open and you want to open the file in new seperate window.如果您打开了现有的 vs 代码 window 并且您想在新的单独 window 中打开文件,您也可以使用 -n 标志。 so the command will be所以命令将是

code D:\testfolder\index.html -n

or或者

code -n D:\testfolder\index.html

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

相关问题 如何关闭从visual studio中打开的“孤立”控制台窗口? - How to close an “orphaned” console window that was opened from within visual studio? 来自 Visual Studio 中控制台项目的 Exe 文件? - Exe file from a console project in Visual Studio? 如何从命令提示符打开 Visual Studio 解决方案文件 - How to open Visual Studio Solution File from the Command Prompt 如何在运行时打开控制台[C ++ / Visual Studio] - How to open Console during runtime [C++/Visual Studio] 如何从 Visual Studio 代码备份文件 laravel 替换它 - How to backup the file from Visual studio code laravel replaced it 如何从 Visual Studio Code 的上下文菜单中删除“用代码打开”? - How do I remove 'open with code' from my context menu for Visual Studio Code? 如何使用葡萄牙语打印到 Visual Studio Code 控制台? - How can I print to the Visual Studio Code console in Portuguese? 如何在给出额外输入的情况下使控制台输出窗口在Visual Studio 2015中保持打开状态? - How to make the console output window stay open in Visual Studio 2015 stay open when extra input is given? 从 windows 上的 ubuntu bash 终端打开 Visual Studio(不是 Visual Studio 代码) - Open Visual Studio (Not Visual Studio Code) from the ubuntu bash terminal on windows 在不访问 powershell 的情况下使用 visual studio 代码 - Using visual studio code without access to powershell
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM