Find - ABC
Replace ABC & Line Number
How can I do this?
Replace ABC & Line Number
How can I do this?
Code: Select all
if (UltraEdit.document.length > 0) // Is any file opened?
{
// Define environment for this script.
UltraEdit.insertMode();
if (typeof(UltraEdit.columnModeOff) == "function") UltraEdit.columnModeOff();
else if (typeof(UltraEdit.activeDocument.columnModeOff) == "function") UltraEdit.activeDocument.columnModeOff();
// Define the parameters for the find.
UltraEdit.ueReOn();
UltraEdit.activeDocument.findReplace.mode=0;
UltraEdit.activeDocument.findReplace.matchCase=true;
UltraEdit.activeDocument.findReplace.matchWord=false;
UltraEdit.activeDocument.findReplace.regExp=false;
UltraEdit.activeDocument.findReplace.searchDown=true;
if (typeof(UltraEdit.activeDocument.findReplace.searchInColumn) == "boolean")
{
UltraEdit.activeDocument.findReplace.searchInColumn=false;
}
// Find case-sensitive all occurrences of "ABC" and replace
// them by "ABC" + current line number.
UltraEdit.activeDocument.top();
while (UltraEdit.activeDocument.findReplace.find("ABC"))
{
var sLineNum = UltraEdit.activeDocument.currentLineNum.toString(10);
UltraEdit.activeDocument.write("ABC"+sLineNum);
}
UltraEdit.activeDocument.top();
}