Title Text


    const deleteAllLogStatements = vscode.commands.registerCommand('extension.deleteAllConsole', () => {
        const editor = vscode.window.activeTextEditor;
        if (!editor) { 
            vscode.window.showErrorMessage('Can\'t insert log because no document is open');
            return; }

        const document = editor.document;
        const documentText = editor.document.getText();

        let workspaceEdit = new vscode.WorkspaceEdit();

        const logStatements = getAllLogStatements(document, documentText);

        deleteFoundLogStatements(workspaceEdit, document.uri, logStatements);
    });
    context.subscriptions.push(deleteAllLogStatements);
npm install -g yo  && npm install -g yo generator-code

yo code

Initial setup

import * as vscode from 'vscode';

const findSyn = (context: vscode.ExtensionContext) =>{
	let disposable = vscode.commands.registerCommand('extension.findSynonym', () => {
		vscode.window.showInformationMessage('Hello Worldaaaaa!');
	});

	context.subscriptions.push(disposable);
}

export function activate(context: vscode.ExtensionContext) {
	console.log('Congratulations, your extension "typescript" is now active!');
	
	findSyn(context);
}

export function deactivate() {}
import * as vscode from 'vscode';

const findSyn = (context: vscode.ExtensionContext) =>{
	let disposable = vscode.commands.registerCommand('extension.findSynonym', () => {
		vscode.window.showInformationMessage('Hello Worldaaaaa!');
	});

	context.subscriptions.push(disposable);
}

export function activate(context: vscode.ExtensionContext) {
	console.log('Congratulations, your extension "typescript" is now active!');
	
	findSyn(context);
}

export function deactivate() {}
const editor =vscode.window.activeTextEditor;
	if(!editor){
		vscode.window.showErrorMessage("Editor doesnot exist")
		return
	}
	const text = editor.document.getText(editor.selection);
	editor.edit(edit => {edit.replace(editor.selection, item.label);});

Replace text of editor

const quickPick = vscode.window.createQuickPick();
		quickPick.items = data.map((x:any) => ({ label: x.word }));
		quickPick.onDidChangeSelection(([item]) => {
			if(item){
				editor.edit(edit => {
					edit.replace(editor.selection, item.label);
				  });
			}
		});
		quickPick.onDidHide(() => quickPick.dispose());
		quickPick.show();

Quick pick

http://www.datamuse.com/api/
 `https://api.datamuse.com/words?ml=${text.replace(" ", "+")}`
"keybindings": [
            {
                "command": "extension.insertConsole",
                "key": "shift+ctrl+l",
                "mac": "shift+cmd+l",
                "when": "editorTextFocus"
            },
            {
                "command": "extension.deleteAllConsole",
                "key": "shift+ctrl+d",
                "mac": "shift+cmd+d"
			},
			{
                "command": "extension.quicPickExample",
                "key": "shift+ctrl+p",
                "mac": "shift+cmd+p"
			}
        ]

Key bindings

import * as vscode from 'vscode';
import fetch from "node-fetch";


const findSyn = async(context: vscode.ExtensionContext) =>{
	let disposable = vscode.commands.registerCommand('extension.findSynonym', () => {
		vscode.window.showInformationMessage('Hello Worldaaaaa!');
	});

	const editor =vscode.window.activeTextEditor;
	if(!editor){
		vscode.window.showErrorMessage("Editor doesnot exist")
		return
	}
	const text = editor.document.getText(editor.selection);

	const response = await fetch(
        `https://api.datamuse.com/words?ml=${text.replace(" ", "+")}`
      );
    const data = await response.json();
	console.log("data",data)

	const quickPick = vscode.window.createQuickPick();
		quickPick.items = data.map((x:any) => ({ label: x.word }));
		quickPick.onDidChangeSelection(([item]) => {
			if(item){
				editor.edit(edit => {
					edit.replace(editor.selection, item.label);
				  });
			}
		});
		quickPick.onDidHide(() => quickPick.dispose());
		quickPick.show();


	context.subscriptions.push(disposable);
}

export function activate(context: vscode.ExtensionContext) {
	console.log('Congratulations, your extension "typescript" is now active!');
	
	findSyn(context);
}

export function deactivate() {}

deck

By Aishwarya Shrestha