Re-select pasted text?

Help with writing and playing macros

Re-select pasted text?

Postby RobOtter » Thu Nov 09, 2006 9:05 am

Hi,

I'd like to create a macro to move a selected text with the keyboard. Therefore in my macro, I would cut a selected text, move the cursor one step in the desired direction and then paste the text. Ok so far.
But to do this repeatedly, the macro must re-select the pasted text. How could I do that? I think it is not possible to count the number of characters in the clipboard or of the selection?

TIA,
Rob
User avatar
RobOtter
Newbie
 
Posts: 4
Joined: Mon Oct 23, 2006 11:00 pm

Re: Re-select pasted text?

Postby Bego » Thu Nov 09, 2006 12:01 pm

Hi Rob,

reselection and undo are not possible via macro.
But why don't you just use cut & paste as normal ?
Where is the benefit ?

Well, for a SINGLE line, it IS possible.
Best, bind those 2 move-macros to shift-ctrl-ArrowUp / shift-ctrl-ArrowDown :-)

rds Bego

Makro setDefaults (use YOUR favorite default settings for it...)
Code: Select all
InsertMode
ColumnModeOff
HexOff
UnixReOn
Clipboard 0



Makro MoveLineUp:
Code: Select all
InsertMode
ColumnModeOff
HexOff
IfSel
Else
Clipboard 9
SelectLine
Cut
Key DOWN ARROW
Paste
Key UP ARROW
EndIf
PlayMacro 1 "setDefaults"



Makro MoveLineDown:
Code: Select all
InsertMode
ColumnModeOff
HexOff
IfSel
Else
Clipboard 9
SelectLine
Cut
Key DOWN ARROW
Paste
Key UP ARROW
EndIf
PlayMacro 1 "setDefaults"
User avatar
Bego
Master
Master
 
Posts: 357
Joined: Wed Nov 24, 2004 12:00 am
Location: Germany

Re: Re-select pasted text?

Postby Mofi » Thu Nov 09, 2006 2:25 pm

Why do you want to select the pasted text again?

The text is still in the clipboard after paste and can be pasted as often as you want without selecting it again.

However, you can select it again by search for the clipboard content:

Find Up "^c"

This works for clipboard content with a maximum of 30,000 characters (since v9.20).
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4066
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Re-select pasted text?

Postby Bego » Thu Nov 09, 2006 3:24 pm

Tag Mofi,

I THINK he wants to "VISUALLY move" some lines up or down.
User avatar
Bego
Master
Master
 
Posts: 357
Joined: Wed Nov 24, 2004 12:00 am
Location: Germany

Re: Re-select pasted text?

Postby RobOtter » Thu Nov 09, 2006 7:48 pm

Hi Bego, hi Mofi!

Yep, Bego, you're right, I want to visually move text lines. Since I discovered this feature in Eclipse, I'm eager to have it in UE also. The next logical step was of course to be able to move portions of text to the left and right also.
BIG thanks Mofi for that great tip using "Find" - it does a great job!
Bego, thanks for your scripts! I had done the same in the beginning, then I've found the "SelectLine" command, making things a bit easier. A great idea is to have a macro with default settings to restore them after a macro - I will incorporate that in all future macros.

These are my VisualMove (tm) macros right now:

Move sel left

Code: Select all
Clipboard 8
InsertMode
ColumnModeOff
Cut
Key LEFT ARROW
Paste
Find Up "^c"
Clipboard 0


Move sel right

Code: Select all
Clipboard 8
InsertMode
ColumnModeOff
Cut
Key RIGHT ARROW
Paste
Find Up "^c"
Clipboard 0


Move line down

Code: Select all
Clipboard 8
InsertMode
ColumnModeOff
SelectLine
Cut
Key DOWN ARROW
Paste
Key UP ARROW
Clipboard 0


Move line up

Code: Select all
Clipboard 8
InsertMode
ColumnModeOff
SelectLine
Cut
Key UP ARROW
Paste
Key UP ARROW
Clipboard 0


Copy line down

Code: Select all
DupeLine


Copy line up

Code: Select all
DupeLine
Key UP ARROW
User avatar
RobOtter
Newbie
 
Posts: 4
Joined: Mon Oct 23, 2006 11:00 pm


Return to Macros