Peer
New line at same level of tab indent

Script key: New line at same level of tab indent

Posted by @ComplexPoint

Install

Details

Label Peer
Voice Over New line at same level of tab indent
Script
drafts = this;

var	lstRange = drafts.getSelectedLineRange(),
	iSelnStart = lstRange[0],
	lngSeln = lstRange[1],
	iSelnEnd = iSelnStart + lngSeln;

var	lstLines = drafts.getTextInRange(iSelnStart, lngSeln).split(/\n/),
	strLine = lstLines.length ? lstLines[0] : '',
	lstMatches = strLine ? strLine.match(/^\t+/) : [],
	strIndent = (lstMatches && lstMatches.length ? lstMatches[0] : '');	
drafts.setTextInRange(
	iSelnEnd, 0, strIndent + '\n'
);
drafts.setSelectedRange(iSelnEnd + strIndent.length, 0);

Advanced

Keyboard shortcut Command+G
Hide key Yes

Discussion

comments powered by Disqus