第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何在 Visial Studio Code 擴(kuò)展開發(fā)中為命令“explorer.newFile”

如何在 Visial Studio Code 擴(kuò)展開發(fā)中為命令“explorer.newFile”

explorer.newFile如何在 Visual Studio Code 擴(kuò)展開發(fā)中為命令提供參數(shù)?我只是想添加在資源管理器視圖中創(chuàng)建一個(gè)具有特定名稱的文件,然后打開它并插入一個(gè)片段,這些操作將在函數(shù)中實(shí)現(xiàn)。幫助^_^
查看完整描述

1 回答

?
九州編程

TA貢獻(xiàn)1785條經(jīng)驗(yàn) 獲得超4個(gè)贊

我當(dāng)然可能是錯(cuò)的,但我不確定explorer.newFile是否會(huì)爭論。


盡管如此,這個(gè)函數(shù)將執(zhí)行您想要的操作:創(chuàng)建一個(gè)文件,打開它,然后插入一個(gè)現(xiàn)有的代碼片段:


async function createFileOpen() {


  const we = new vscode.WorkspaceEdit();


  const thisWorkspace = await vscode.workspace.workspaceFolders[0].uri.toString();


  // if you want it to be in some folder under the workspaceFolder: append a folder name

  // const uriBase = `${thisWorkspace}/folderName`; 

  // let newUri1 = vscode.Uri.parse(`${uriBase}/index.js`);


  // create a Uri for a file to be created

  const newUri = await vscode.Uri.parse(`${ thisWorkspace }\\myTestIndex.js`);

  

  // create an edit that will create a file

  await we.createFile(newUri, { ignoreIfExists: false, overwrite: true });


  await vscode.workspace.applyEdit(we); // actually apply the edit: in this case file creation


  await vscode.workspace.openTextDocument(newUri).then(

    async document => {      

      await vscode.window.showTextDocument(document);

      // if you are using a predefined snippet

      await vscode.commands.executeCommand('editor.action.insertSnippet', { 'name': 'My Custom Snippet Label Here'});

    });

}


查看完整回答
反對(duì) 回復(fù) 2023-10-20
  • 1 回答
  • 0 關(guān)注
  • 145 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)