2017-08-01 53 views
0

当与团队成员快速分享代码时,最好将带有行号的代码粘贴到电子邮件/文档中。如何使用UltraEdit复制带数字的代码?

有谁知道如何用UltraEdit做到这一点?

目前存在的问题:下面

1 PRINT 'WHAT IS YOUR NAME?' 
2 INPUT NAME 
3 PRINT 'HELLO':NAME 

无选项选择的代码复制/粘贴行号,以便粘贴的样子:提前

PRINT 'WHAT IS YOUR NAME?' 
INPUT NAME 
PRINT 'HELLO':NAME 

感谢。

回答

0

我收到了回信从IDM电脑解决方案这个问题(用UltraEdit的制片人):

谢谢您的留言。我很抱歉地说这个功能目前不可用。

但之前我们已经要求过,我们正在考虑它。我已经将您的联系方式添加到了我们关于该主题的日志中,并且我们会在发布包含此功能的更新版本时通知您。

1

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。然后将此脚本添加到脚本列表没有热键用于在将块复制到剪贴板或使用快捷键或和弦(多键分配)将键快速执行后从脚本列表执行。

脚本本身也可以制作所选文本的副本。

当在活动文件中选定的文本上执行此脚本的稍微修改版本而不是剪贴板内容时,也可以在活动文件中使用实际行号。

相关问题