⌘X
Cut

Script key: Cut

Posted by Sublime Text ⌘X

Install

Details

Label ⌘X
Voice Over Cut
Script
var text = getText()
var n = text.length
var selRange = getSelectedRange()

var i, j

if (!selRange[1])
  selectLine()

setClipboard(getSelectedText())
setSelectedText("")


function selectLine() {
 
  
  i = selRange[0]
  var delim = /^[\n]$/
  
  while (i > 0) {
    if (delim.test(text[i - 1]))
      break
  
    --i
  }
  
  j = selRange[0]+selRange[1]
  
  while (j < n) {
    if (delim.test(text[j]))
      break
    ++j
  }

  ++j
  
  if (j-i)
    setSelectedRange(i, j-i)
}

Advanced

Keyboard shortcut None
Hide key Yes

Discussion

comments powered by Disqus