⌃K
Cut from cursor to end of line, or cut selection.

Script key: Cut from cursor to end of line, or cut selection.

Posted by shirose_jp

Install

Details

Label ⌃K
Voice Over Cut from cursor to end of line, or cut selection.
Script
// Cut from cursor to end of line, or cut selection.
// カーソルから行末までカット(選択範囲をカット)

var range = getSelectedRange();
var line_range = getSelectedLineRange();

var eol = line_range[0] + line_range[1];
if ( getTextInRange( eol - 1, 1 ) === '\n' ) {
  eol = eol - 1;
}

if ( isSelect() === true ) {
  setClipboard( getSelectedText() );
  setSelectedText( '' );
  setSelectedRange( range[0], 0 );
} else {
  setClipboard( getTextInRange( range[0], eol - range[0] ) );
  setTextInRange( range[0], eol - range[0], '' );

  setSelectedRange( range[0], 0 );
}

function isSelect() {
  if ( getSelectedText().length > 0 ) {
    return true;
  } else {
    return false;
  }
}

Advanced

Keyboard shortcut None
Hide key Yes

Discussion

comments powered by Disqus