本文整理匯總了TypeScript中vscode.TextEditorEdit.replace方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript TextEditorEdit.replace方法的具體用法?TypeScript TextEditorEdit.replace怎麽用?TypeScript TextEditorEdit.replace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vscode.TextEditorEdit
的用法示例。
在下文中一共展示了TextEditorEdit.replace方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1:
textEditor.selections.forEach((selection) => {
let text = doc.getText(selection);
let value = Number.parseFloat(text.replace('px', ''));
let result = value / factor;
let fixed = Number.parseFloat(result.toFixed(decimals));
edit.replace(selection, fixed + unit);
});
示例2: Position
return editor.edit((editBuilder: TextEditorEdit) => {
const doc = editor.document;
const startPos = new Position(0, 0);
const lastLine = doc.lineAt(doc.lineCount - 1);
const endPos = lastLine.range.end;
const entireRange = new Range(startPos, endPos);
editBuilder.replace(entireRange, text);
editBuilder.setEndOfLine(EndOfLine.LF);
});
示例3: applyUsingTextEditorEdit
// Applies Edit using given TextEditorEdit
applyUsingTextEditorEdit(editBuilder: TextEditorEdit): void {
switch (this.action) {
case EditTypes.EDIT_INSERT:
editBuilder.insert(this.start, this.text);
break;
case EditTypes.EDIT_DELETE:
editBuilder.delete(new Range(this.start, this.end));
break;
case EditTypes.EDIT_REPLACE:
editBuilder.replace(new Range(this.start, this.end), this.text);
break;
}
}
示例4: updateTask
private updateTask(taskLine: TextLine, taskDescription: string, symbol: string, tag?: string) {
this._textEditorEdit.replace(new Range(new Position(taskLine.lineNumber, taskLine.firstNonWhitespaceCharacterIndex), taskLine.range.end), symbol + " " + taskDescription + (tag ? (" " + TodoDocument.toTag(tag)) : ""));
new TodoDocumentDecorator(this._textEditor).performDecoration();
}
示例5:
window.activeTextEditor.edit((textEditorEdit: TextEditorEdit) => {
textEditorEdit.replace(te.range, te.newText);
});