unindent

Script key: unindent

Posted by minime

Install

Details

Label
Voice Over unindent
Script
// indent selected lines

var lnRange = getSelectedLineRange();
var ln = getTextInRange(lnRange[0],lnRange[1]);
var selRange = getSelectedRange();

var lines = ln.split('\n');
var charsRemoved = 0;

for (var ix=0; ix < lines.length; ix++) {
  if (lines[ix].length > 0) {
     lines[ix] = lines[ix].substring(1, lines[ix].length);
     charsRemoved++;
  }
}

setTextInRange(lnRange[0],lnRange[1],lines.join("\n"));
if (lines.length > 2) {
  setSelectedRange(lnRange[0]+lnRange[1]-charsRemoved, 0);
}
else {
  setSelectedRange(selRange[0]-charsRemoved,selRange[1]);
}

Advanced

Keyboard shortcut None
Hide key Yes

Discussion

comments powered by Disqus