✪ Pad
Add double spaces to lines for markdown

Script key: Add double spaces to lines for markdown

Posted by @GilsDesk

Install

Details

Label ✪ Pad
Voice Over Add double spaces to lines for markdown
Script
// Pad line endings with two spaces in selected text, or entire Draft if nothing selected. 
// Cursor returns to start of Draft if entire Draft was padded. 
// Cursor returns to start of selected text if text was selected prior to running. 
// Important: If you select line(s) to be padded, ensure that your selection includes the final newline character of your last line, if you want that line to be padded. 
// This usually means your selection wil end at the very start of the next line. 

var s = getSelectedText();
if (s.length > 0) {
var sel_start = getSelectedRange();
var res = s.replace(/\n/gm,'  \n');
setSelectedText(res);
setSelectedRange(sel_start[0],0);
} else {
var t = getText();
var res = t.replace(/\n/gm,'  \n');
setText(res);
setSelectedRange(0,0);
}

Advanced

Keyboard shortcut None
Hide key Yes

Discussion

comments powered by Disqus