Drafts Action Directory

Single space

Posted by dchar, Last update 3 months ago

Remove blank lines from a selection or draft.

Install

Steps

  • script

    // single space
    
    (() => {
    
      const getLines = () => {
        const e = editor;
        const t =
          e.getSelectedRange()[1] > 0 ?
          e.getTextInRange(...e.getSelectedLineRange()) :
          e.getText();
        return t.split('\n');
      };
    
      const setLines = (l) => {
        const t = l.join('\n') + '\n';
        const e = editor;
        if (e.getSelectedRange()[1] > 0) {
          const sel = e.getSelectedLineRange();
          e.setTextInRange(sel[0], sel[1], t);
          e.setSelectedRange(sel[0], t.length);
        } else {
          e.setText(t);
        }
      };
    
      const single = (l) => {
        return l.filter(l => l.trim());
      }
    
      setLines(single(getLines()));
    
    })();

Options

  • After Success Default
    Notification Info
    Log Level Info

Comments

Actions available in the Action Directory are uploaded by community members. Use appropriate caution reviewing downloaded actions before use.