Randomize Lines

Posted by @DavidAns, Last update over 5 years ago

Randomizes the order of all lines in a draft.

Handy for mixing up vocabulary words and other lists for memorization.


  • script

    // Randomizes the order of all lines in a draft
    const beforeText = editor.getText();
    const lines = beforeText.trim().split("\n");
    for (let i = 0 ; i < lines.length - 1 ; i++) {
      const j = Math.floor(Math.random() * lines.length);
      const line = lines[j];
      lines[j] = lines[i];
      lines[i] = line;
    const afterText = lines.join("\n");


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