Count

Script key

Posted by @sebastinez87

Install

Details

Label Count
Voice Over
Script
var line = getSelectedLineRange();
var linetext = getTextInRange(line[0], line[1]);

if (linetext) {
setSelectedRange(line[0]+line[1]-1,0);
var cursor = getSelectedRange();
//alert(line+"|"+cursor);

var re = new RegExp("[0-9]{1,6}", "gm");
var match = linetext.match(re);
//alert(match);
if (match) {
var l = match[0].toString();

var number = setSelectedRange(cursor[0]-l.length,l.length);
var h = getSelectedText();

var newt = linetext.replace(re,++h);
setSelectedRange(line[0],line[1]);
setSelectedText(newt);
setSelectedRange(cursor[0],0);
} else {
setSelectedRange(line[0]+line[1]-1,0);
setSelectedText(" 0");
setSelectedRange(line[0]+line[1]-1,0);
}
} else {

var newt = "0\n";
setSelectedRange(line[0],0);
setSelectedText(newt);
setSelectedRange(line[0]+line[1],0);
}

Advanced

Keyboard shortcut None
Hide key Yes

Discussion

comments powered by Disqus