繁体   English   中英

在 VSCode 中获取当前打开的文件

[英]Getting the currently open file in VSCode

vscode命名空间中是否有允许您获取当前打开文件的TextDocument实例的命令? 我找到了vscode.workspace.onDidOpenTextDocument ,但它不适用于启动时打开的文件

根据您的需要提供一些选项:

// Single active editor. Editors have a `.document` property
vscode.window.activeTextEditor

// All showing text editors. For a split view, there are two active editors 
vscode.window.visibleTextEditors

// All open documents that vscode knows about. Do not have to be showing
vscode.workspace.textDocuments

有关更多信息,请参阅 vscode API: https ://code.visualstudio.com/docs/extensionAPI/vscode-api

暂无
暂无

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

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