Move / Copy Lines Macro

Help with writing and playing macros

Move / Copy Lines Macro

Postby meltdown » Sat Mar 12, 2005 12:12 pm

One thing I really like about Eclipse is some of the keyboard shortcuts it has by default. One of which is the move/copy lines shortcut ability. In Eclipse you can hold the Alt key and press the up or down arrows and it will move the current line up or down. You can also use Ctrl+Alt+Arrow key to copy the current line. Both of these can be used while selecting multiple lines to accomplish the same thing but with a group of lines. Does anyone know how to setup UE to do this?
User avatar
meltdown
Newbie
 
Posts: 3
Joined: Sat Mar 12, 2005 12:00 am

Re: Move / Copy Lines Macro

Postby mrainey56 » Sat Mar 12, 2005 3:49 pm

I use these all the time, assigned to keystrokes.



Current Line Up:

Key HOME
StartSelect
Key END
Cut
Key DEL
Key UP ARROW
"
"
Key UP ARROW
Paste
Key HOME


Current Line Down:

Key HOME
StartSelect
Key END
Cut
Key DEL
Key DOWN ARROW
"
"
Key UP ARROW
Paste
Key HOME


Copy Current Line:

InsertMode
ColumnModeOff
HexOff
UnixReOn
Key HOME
StartSelect
Key END
Copy
EndSelect
Key HOME


Duplicate Current Line:

Key HOME
StartSelect
Key END
Copy
EndSelect
Key END
"
"
Paste
Key HOME
User avatar
mrainey56
Master
Master
 
Posts: 212
Joined: Tue Jul 27, 2004 11:00 pm
Location: Spartanburg, South Carolina

Re: Move / Copy Lines Macro

Postby MrBillG » Sat Mar 12, 2005 10:24 pm

Hi mrainey56

Thanks for sharing!
User avatar
MrBillG
Advanced User
Advanced User
 
Posts: 65
Joined: Sat Aug 07, 2004 11:00 pm

Re: Move / Copy Lines Macro

Postby meltdown » Sun Mar 13, 2005 8:55 am

mrainey56,

Thanks for your reply. What you offered was along the along lines of what I was looking for, but not exactly. A couple issues I notice:

1) When I use the HOME key the cursor goes to the beginning of the text (after any indentation). This is desired behavior for the most part (I believe there is a pref that allows this behavior to be changed). When this happens and the following line had indentation the following line loses it proper spacing.

2) When the line that was cut/copied is pasted one line up (using the up macros) it is pasted at the beginning of the line, I think an extra new line is needed.

3) It would be nice if it didn't overwrite what was in your clipboard (I guess it could be modified to use an alternate clipboard).

4) Would be nice if this supported multiple line selections, not sure if this is possible.

Sorry to sound like I'm criticizing, just wanted to see if anyone have suggestions for my needs. :)
User avatar
meltdown
Newbie
 
Posts: 3
Joined: Sat Mar 12, 2005 12:00 am

Re: Move / Copy Lines Macro

Postby mrainey56 » Sun Mar 13, 2005 11:12 am

meltdown,

You're correct that different UE configurations could affect how these macros function. They've worked perfectly for me for several years now, with my configuration and my way of doing things. They might not give you what you need.

At the least, they might give you some ideas for creating your own macros.


Mike
User avatar
mrainey56
Master
Master
 
Posts: 212
Joined: Tue Jul 27, 2004 11:00 pm
Location: Spartanburg, South Carolina

Re: Move / Copy Lines Macro

Postby palou » Mon Mar 14, 2005 3:03 am

Hi meltdown,

There is some responses to your issues:

1) -> Add a second Key HOME to ever go at the beginning of a line

2) -> Try this code to select/cut the line:
Code: Select all
Key HOME
Key HOME
StartSelect
Key DOWN ARROW
Cut


3) -> Add a Clipboard 9 at the beginning of the macro and a
Clipboard 0 at the end (9 is which I personally use, you can choose
yours)

4) -> Put the Select/cut part in the Else section of an IfSel test.

If you need an example, this is what the Current Line Up macro
should like:
Code: Select all
Clipboard 9
IfSel
Cut
Else
Key HOME
Key HOME
StartSelect
Key DOWN ARROW
Cut
EndIf
Key UP ARROW
Paste
Key HOME
Clipboard 0


Two remarks:

a) The selection doesn't works on the last line of the file :(
b) I'm not responsible for the result in case of the selection
doesn't start and/or doesn't stop at the beginning of a line. ;)

HTH (Hope This Help)
Alain
User avatar
palou
Basic User
Basic User
 
Posts: 46
Joined: Fri Dec 17, 2004 12:00 am
Location: Geneva / Switzerland

Re: Move / Copy Lines Macro

Postby meltdown » Mon Mar 14, 2005 7:23 am

Thanks, I'll try playing with them at work today. :)
User avatar
meltdown
Newbie
 
Posts: 3
Joined: Sat Mar 12, 2005 12:00 am


Return to Macros