Moving cursor to opposite end of a selection

This forum is user-to-user based and not regularly monitored by IDM.
Please see the note at the top of this page on how to contact IDM.

Moving cursor to opposite end of a selection

Postby writerlywriter » Mon Aug 24, 2009 4:03 am

Hi, this is probably a newbie question but I've searched around and I can't find a way to do this.

If I've selected some text in UltraEdit, is there a way to move the cursor to the opposite end of the selection without affecting the selection range?

Say I have the following selected text (non-selected text in blue; selected text in red; cursor in green):

This is some |test text.

I'm looking for a keypress or other method I can use to alter the cursor position as follows:

This is some test| text.

This would then allow me to alter the selection range on the opposite end to my original cursor position.

Is this possible?
writerlywriter
Newbie
 
Posts: 3
Joined: Mon Aug 24, 2009 3:50 am

Re: Moving cursor to opposite end of a selection

Postby Mofi » Mon Aug 24, 2009 5:00 am

There is no possibility (as far as I know) to move the cursor while a selection is active without modifying the selection.

There is the Find Select method and the Goto Bookmark Select method which are often used to select something from current cursor position to end of a found string or from current cursor position to bookmark.


From help of UltraEdit, page about the Find command:

To select all text between the cursor position and the search target, hold down the SHIFT key at the time the search is started with the Find Next button.


From help of UltraEdit, page about the Goto Line/Page/Bookmark command:

When the Shift key is pressed at the same time as performing the Goto function, the current selection (if present) or a new selection will be extended to select text up to the cursor position following the command.


Both work also in reverse direction (upwards), for example when using Find Prev.

Note: An existing selection at cursor position is taken into account by expanding/reducing the selection to end of found string or bookmark.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4042
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Moving cursor to opposite end of a selection

Postby writerlywriter » Mon Aug 24, 2009 10:31 am

Thanks for your response Mofi. After some experimentation, I found that I could do this easily with a macro as long as I want to move the cursor from the top of a selection to the bottom:

Code: Select all
InsertMode
ColumnModeOff
HexOff
Find Select SelectText "^s"

This relies on a UltraEdit's behaviour of placing the cursor after a found string, which means that a different solution is required to move the cursor from the bottom to the top of a selection. Here's what I have so far:

Code: Select all
InsertMode
ColumnModeOff
HexOff
Cut
"¬"
Paste
StartSelect
Find Up Select "¬"

(Replace "¬" with any character you don't intend to use in the type of file you're working with.)

This relies on the same behaviour of placing the cursor after a found string. But it's a real kludge, because the selected text now starts with an extraneous "¬". Any ideas?
writerlywriter
Newbie
 
Posts: 3
Joined: Mon Aug 24, 2009 3:50 am

Re: Moving cursor to opposite end of a selection

Postby Bego » Mon Aug 24, 2009 11:30 am

There is the option to use "persistent selections" (Edit menu). As far as I know, it is not possible in macros. (It does not record it).
But I made it to jump to the beginning of a persistent selection by pressing ctrl+LMB at the start of the selection.
see online help about it:
Code: Select all
"The anchor point for the active selection may be changed by holding down the CTRL key and left-clicking with the mouse at the desired file position. "

Maybe this one is for you
User avatar
Bego
Master
Master
 
Posts: 357
Joined: Wed Nov 24, 2004 12:00 am
Location: Germany

Re: Moving cursor to opposite end of a selection

Postby Mofi » Tue Aug 25, 2009 1:19 am

Code: Select all
InsertMode
ColumnModeOff
HexOff
Find SelectText "^s"

is working only for selection with up to 30.000 bytes. If the selection is larger, it will not work.

Code: Select all
InsertMode
ColumnModeOff
HexOff
Clipboard 9
Cut
ToggleBookmark
Paste
ClearClipboard
Clipboard 0
PreviousBookmarkSelect
ToggleBookmark

works for moving the cursor from end to start of a selection if the configuration setting Bookmark column with line at Advanced - Configuration - Editor - Bookmarks.

It would be maybe better to code that cursor moving in selection commands with a script. With a script you can get and store the current line and column number in variables and get also the current selection into a string variable. Then you can count how many line endings are in the string and how many characters are selected in the last line of the selection. With that data you can calculate the line and column number of the opposite end of the selection. Now you can unselect the selection set the cursor to correct position and use command gotoLineSelect to select to the other position. The big advantage of a script using the described method is that nearly no limit exists (as long as you have not hundreds of MBs selected) and no undo steps are produced.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4042
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Moving cursor to opposite end of a selection [SOLVED]

Postby writerlywriter » Fri Sep 04, 2009 5:39 am

Thanks Mofi, that's absolutely fine for my purposes.

In fact, I've since found out that the Vim editor does just what I wanted (when in Visual mode, you can hit 'o' to move the cursor to the opposite end of a selection), as well as a range of other powerful movement commands. I've just installed gVim (the graphical version of Vim) and I think I'm much more comfortable with it. As a very keyboard-driven user, the case may be that UltraEdit simply isn't quite the right editor for me.

Regardless, thank you very much for the assistance you've given me in this thread!
writerlywriter
Newbie
 
Posts: 3
Joined: Mon Aug 24, 2009 3:50 am


Return to UltraEdit General Discussion