Is there a command in the vscode
namespace that allows you to get the TextDocument
instance for the currently open file? I found vscode.workspace.onDidOpenTextDocument
, but it doesn't work for files that are open on launch
A few options depending on your needs:
// 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
See the vscode API for more info: https://code.visualstudio.com/docs/extensionAPI/vscode-api
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With