Advertisement
FichteFoll

JS: UEStudio - Imitate SciTE's Ctrl-D behaviour

Feb 26th, 2012
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // This script will imitate SciTE's Ctrl-D behaviour
  2. // That is, dublicate the line or dublicate the selection
  3. // FichteFoll, 26.02.2012
  4.  
  5.  
  6. // wrap into an anonymous function
  7. (function() {
  8.     // aliases
  9.     var ue = UltraEdit;
  10.     var doc = ue.activeDocument;
  11.     //~ var out = ue.outputWindow;
  12.  
  13.     if (!doc.isSel()) {
  14.         // just dublicate the current line if there is no selection
  15.         doc.dupeLine();
  16.         out.write(doc.selection);
  17.     }
  18.     else {
  19.         var sel = doc.selection, pos = [doc.currentLineNum, doc.currentColumnNum];
  20.         doc.gotoLine(pos[0], pos[1]); // will go to the start of the selection, i.e. first selected char
  21.         doc.write(sel);
  22.         // select the previously selected text again
  23.         doc.gotoLineSelect(pos[0], pos[1]);
  24.     }
  25.     return 1;
  26. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement