⚡️¶
Remove line breaks

Script key: Remove line breaks

Posted by Cowpi

Install

Details

Label ⚡️¶
Voice Over Remove line breaks
Script
// Removes line breaks while 
// preserving double line breaks.
// Also removes multiple spaces. 

isSelectionEmpty = getSelectedText() == '';
draft = isSelectionEmpty ? getText() : getSelectedText();

newText = draft.replace(/(^|[^\n])\n(?!\n)/g, '$1 ');
newText = newText.replace(/ {2,}/g, ' ');

if (isSelectionEmpty)
    setText(newText);
else
    setSelectedText(newText);

Advanced

Keyboard shortcut None
Hide key Yes

Discussion

comments powered by Disqus