簡體   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