«
Dedent. Remove one leading tab from selected lines.

Script key: Dedent. Remove one leading tab from selected lines.

Posted by @jeremywsherman

Install

Details

Label «
Voice Over Dedent. Remove one leading tab from selected lines.
Script
// API docs: https://agiletortoise.zendesk.com/hc/en-us/articles/202465564-Script-Keys
// Based on: http://drafts4-actions.agiletortoise.com/k/1CO

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

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

for (var ix=0; ix < lines.length; ix++) {
  var line = lines[ix];
  if (line.length > 0 && line[0] == "\t") {
    lines[ix]= line.slice(1);
    charsAdded -= 1;
  }
}

var text = lines.join("\n");
setTextInRange(lnRange[0],lnRange[1], text);
setSelectedRange(lnRange[0], text.length > 0 ? text.length - 1 : text.length);

Advanced

Keyboard shortcut Command+{
Hide key Yes

Discussion

comments powered by Disqus