Advertisement
rplantiko

UltraEdit - pad selected lines with spaces to given length

Apr 30th, 2014
601
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Pad selected lines with spaces up to the given pad length
  2.  
  3. // Cut selected text into array selectedLines, separating lineEnd
  4. // include cutSelection.js
  5.  
  6. var padLength = 1*UltraEdit.getString("Pad to length",1);
  7. if (padLength<=0) {
  8.   padLength = Math.max.apply( null, selectedLines.map(
  9.                   function( line ) { return line.length } )
  10.                   );
  11.   }
  12.  
  13. var spaces = Array( padLength + 1).join(' ');
  14.  
  15. var result = selectedLines.map( function( line ) {
  16.   return (line + spaces).substring(0,padLength);
  17.   } ).join( lineEnd );
  18. UltraEdit.activeDocument.write( result );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement