Action

Duplicate Line

Posted by agiletortoise, Last update about 2 years ago

Duplicate the current selected line(s), inserting the new version directly below.

Steps

  • script

    // grab ranges and text
    let [selStart, selLen] = editor.getSelectedRange()
    let [lnStart, lnLen] = editor.getSelectedLineRange()
    let lnText = editor.getTextInRange(lnStart, lnLen)
    let flNeedsLineFeed = !lnText.endsWith("\n") 
    
    // insert duplicate of current line below it
    editor.setTextInRange(lnStart + lnLen, 0, `${flNeedsLineFeed ? "\n" : ""}${lnText}`)
    

Options

  • After Success Nothing
    Notification Error
    Log Level Error
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.