Skip to content

Instantly share code, notes, and snippets.

@ongaeshi
Created January 20, 2021 15:46
Show Gist options
  • Save ongaeshi/df1f642e346922be3c77ae627811af77 to your computer and use it in GitHub Desktop.
Save ongaeshi/df1f642e346922be3c77ae627811af77 to your computer and use it in GitHub Desktop.
c = T.current;
if(c){
s = "[*** " + c + "]"
if(T.range.len){
T("replaceRange", {text:s,
replacingRange:{ loc:T.range.loc, len:c.length },
selectingRange:{ loc:T.range.loc, len:s.length }
} );
}else{
T("replaceCurrent",{text:s});
}
}else{
s = T.pboard;
if(s=="undefined") s = "";
T("insert",{text:s});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment