Select Word

Script key: Select Word

Posted by Xor

Install

Details

Label
Voice Over Select Word
Script
var text = getText()
var selRange = getSelectedRange()

var n = text.length

var i = selRange[0]
//var delim = /^[^\w]$/
var delim = /^[\s]$/

while (i > 0) {
  if (delim.test(text[i - 1]))
    break

  --i
}

var j = selRange[0]+selRange[1]

while (j < n) {
  if (delim.test(text[j]))
    break
  ++j
}

if (j-i)
  setSelectedRange(i, j-i)
/*else if (i)
  setSelectedRange(i-1, 1)
else 
  setSelectedRange(0, 1)*/

Advanced

Keyboard shortcut Command+D
Hide key Yes

Discussion

comments powered by Disqus