I have a list of data that I need to put a ' symbol at the start of the line and at the end of the line. So the original data look like
11223334444xxx55555
11xxx223334444555xxx55
11xxxx22333444xxx455555
11xxxxx22333444455555
11xxxxxx223334444555xxx55
and I want all the line to look like
11223334444yyyy55555
11yyyy223334444555yyyy55
11yyyyx22333444yyyy455555
11yyyyxx22333444455555
11yyyyyyyy223334444555yyyy55
that is 'yyyy' replace 'xxx', how I write my code? Both typescript and javascript are perfect.
Sorry, my bad. I want develop an extension to do it, and above just an example. Many answers below just miss select full text part.
const textEditor = vscode.window.activeTextEditor;
if (!textEditor) {
return; // No open text editor
}
var firstLine = textEditor.document.lineAt(0);
var lastLine = textEditor.document.lineAt(textEditor.document.lineCount - 1);
var textRange = new vscode.Range(0,
firstLine.range.start.character,
textEditor.document.lineCount - 1,
lastLine.range.end.character);
textEditor.edit(function (editBuilder) {
editBuilder.replace(textRange, '$1');
});
});
replace function above just has one replace argument, not two, how can I replace it?