<--
Outdent

Script key: Outdent

Posted by @complexpoint

Install

Details

Label <--
Voice Over Outdent
Script
var	rngSeln=getSelectedRange(),
	iSelnFrom=rngSeln[0], iSelnTo=rngSeln[1],
	rngLines=getSelectedLineRange(),
	iFrom=rngLines[0], iTo=rngLines[1],
	strLines=getTextInRange(iFrom, iTo),
	strOutdented=strLines.replace(/^\t/gm,''),
	lngLines=strLines.trim().split('\n').length;

if (strOutdented.length !== strLines.length) {
	setTextInRange(iFrom, iTo, strOutdented); 
	setSelectedRange(
		iSelnFrom - Number(iSelnFrom > iFrom),
		(iSelnTo - lngLines) + Number(iSelnTo < iTo)
	);
}

Advanced

Keyboard shortcut None
Hide key Yes

Discussion

comments powered by Disqus