So I want to open a file in markdown preview, so when the certain command is triggered I want to open a file in vscode (but in markdown preview mode)
What have I tried so far:
const docs = await workspace.openTextDocument("/path/to/file.md");
await window.showTextDocument(docs);
await commands.executeCommand("markdown.showPreview");
Is there a better way to achieve this, since it take fraction of seconds to open the file and then trigger markdown preview
The markdown markdown.showPreview command takes a uri as its first argument. For example:
const uri = vscode.URI.file("/path/to/file.md");
await commands.executeCommand("markdown.showPreview", uri);
To control the column the editor is opened in, use the markdown.showPreviewToSide command instead. Here are the arguments it takes
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