How to add a new file to the workspace when develo

2019-09-11 01:07发布

Just as I had trouble and it is not that obvious:

How can I add a new file when developing vscode extension?

1条回答
兄弟一词,经得起流年.
2楼-- · 2019-09-11 02:04

First you have to create a command (when using the vscode extension example put it in extension.ts) -> For example the hello world command.

You have to use openTextDocument method on the workspace and get the path for your project. Don't forget that you have to use "\" instead of "/" for the path:

let manifest = await vscode.workspace.openTextDocument(vscode.Uri.parse("untitled:"+vscode.workspace.rootPath+"\\projectmanifest.json"));
await manifest.save();
查看更多
登录 后发表回答