UltraEdit没有内置的命令将选定的行与行号复制到剪贴板。
但是,在将块粘贴到电子邮件应用程序之前,可以运行UltraEdit脚本来将行号添加到复制到剪贴板之前的文本中。
// Get content of clipboard as an array of lines assuming that the
// clipboard contains text data and the lines have carriage return
// plus line-feed as line termination.
if (UltraEdit.clipboardContent.length)
{
var asLines = UltraEdit.clipboardContent.split("\r\n");
// Remove the last string from array if being empty because
// the text in clipboard ends with a line termination.
if (!asLines[asLines.length-1].length) asLines.pop();
// Convert the number of lines to a string using decimal
// system and replace each digit in string by character 0.
var sLeadingZeros = asLines.length.toString(10).replace(/./g,'0');
// Insert at beginning of each line a number with
// leading zeros according to maximum number of lines.
for (var nLine = 0; nLine < asLines.length; nLine++)
{
var sLineNumber = (nLine+1).toString(10);
sLineNumber = sLeadingZeros.substr(sLineNumber.length) + sLineNumber;
if (asLines[nLine].length)
{
asLines[nLine] = sLineNumber + " " + asLines[nLine];
}
else // For an empty line just add the line number without spaces.
{
asLines[nLine] = sLineNumber;
}
}
// Append an empty string to array of lines to have finally the
// block in clipboard terminated with carriage return and line-feed.
asLines.push("");
// Join the modified lines back to a block in clipboard.
UltraEdit.clipboardContent = asLines.join("\r\n");
}
复制&将此脚本代码粘贴到一个新的ANSI文件并将其保存例如与文件名Add Line Numbers.js
。然后将此脚本添加到脚本列表没有热键用于在将块复制到剪贴板或使用快捷键或和弦(多键分配)将键快速执行后从脚本列表执行。
脚本本身也可以制作所选文本的副本。
当在活动文件中选定的文本上执行此脚本的稍微修改版本而不是剪贴板内容时,也可以在活动文件中使用实际行号。