2017-08-01 55 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。然後將此腳本添加到腳本列表沒有熱鍵用於在將塊複製到剪貼板或使用快捷鍵或和絃(多鍵分配)將鍵快速執行後從腳本列表執行。

腳本本身也可以製作所選文本的副本。

當在活動文件中選定的文本上執行此腳本的稍微修改版本而不是剪貼板內容時,也可以在活動文件中使用實際行號。

相關問題