How to add a new file to the workspace when developing a new vscode extension?

时间秒杀一切 提交于 2019-12-25 16:48:43

问题


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

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


回答1:


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();


来源:https://stackoverflow.com/questions/40832729/how-to-add-a-new-file-to-the-workspace-when-developing-a-new-vscode-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!