Drafts Action Directory

Double space

Posted by dchar, Last update about 2 months ago

Double space a draft or a selection.

Install

Steps

  • script

    // double 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, t);
          e.setSelectedRange(sel[0], t.length);
        } else {
          e.setText(t);
        }
      };
    
      const double = (l) => {
        return l.filter(l => l.trim())
          .reduce((xs, l) => { xs.push(l, ''); return xs; }, []);
      };
    
      setLines(double(getLines()));
    
    })();

Options

  • After Success Nothing
    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.