Selecting text

Help with writing and running scripts

Selecting text

Postby jbeck » Tue Apr 17, 2007 9:31 am

Hello

Does anyone know how to select an entire line without selecting the hard return at the end?

selectLine() unfortunately selects the line and the return.

There does not appear to be a key("SHIFT+END") command either.
User avatar
jbeck
Newbie
 
Posts: 6
Joined: Wed Apr 11, 2007 11:00 pm

Re: Selecting text

Postby jorrasdk » Tue Apr 17, 2007 10:00 am

Just do some basic javascript string manipulation after retrieving the selected line. Here is an example.

Code: Select all
String.prototype.nocrlf = function() { return this.replace(/[\r\n]/g, ""); };

UltraEdit.activeDocument.selectLine();
var line = UltraEdit.activeDocument.selection;
UltraEdit.activeDocument.bottom();
UltraEdit.activeDocument.write(line.nocrlf());
UltraEdit.activeDocument.write("-----");


I'm using prototype to add a new method to the string object. The method is some simple regexp.
User avatar
jorrasdk
Master
Master
 
Posts: 275
Joined: Mon Mar 19, 2007 11:00 pm
Location: Denmark

Re: Selecting text

Postby jbeck » Tue Apr 17, 2007 1:32 pm

Thanks jorrasdk, you are obviously a javascript "guru" :)

My experience of javascript has come through UltraEdit!

Jon
User avatar
jbeck
Newbie
 
Posts: 6
Joined: Wed Apr 11, 2007 11:00 pm


Return to Scripts