Skip to content

Instantly share code, notes, and snippets.

@sametoz
Last active January 17, 2021 15:57
Show Gist options
  • Save sametoz/9de3ffd12bd71f93aa790ca995c9ccb7 to your computer and use it in GitHub Desktop.
Save sametoz/9de3ffd12bd71f93aa790ca995c9ccb7 to your computer and use it in GitHub Desktop.
import * as vscode from 'vscode';
export function activate(context: vscode.ExtensionContext) {
console.log('Congratulations, your extension "tertip" is now active!');
const editor = vscode.window.activeTextEditor;
let disposable = vscode.commands.registerCommand('tertip.clearSpaces', () => {
if (editor) {
const document = editor.document;
const selection = editor.selection;
const selectedPortion = document.getText(selection);
const withoutSpaces = selectedPortion.replace(/\s+/g, '');
editor.edit(editBuilder => {
editBuilder.replace(selection, withoutSpaces);
});
vscode.window.showInformationMessage('Everything is non-spaces!');
}
});
context.subscriptions.push(disposable);
}
export function deactivate() {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment