Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
schneidermic0
Advisor
Advisor

Recently, I did some pair programming with one of my colleagues. My colleague showed me the block selection mode. This is a small feature provided by Eclipse which I would like to share with you, today.

I knew this feature for selecting and copying some blocks from my ABAP source code. You can compare it to the short-cut CTRL+Y in SAP GUI. I guess you know this one.

This functionality on its own is already very helpful, but I didn't know that you can use this mode also to edit source code in an Eclipse editor. Therefore, here is the whole story...

We were in the following situation: We wanted to write an ABAP Unit test that has to add some source code to an internal table that has to be processed by the test. We just copied the source code for the test in our test method.

In the past, I changed the coding manually by going through each line and adding APPEND ' in the front and ' TO SOURCE_CODE. at the end of each line. Sometimes I created a small macro to save some time. But still than, I had to surround each source code line with the quote sign.

Block selection mode in Eclipse allowed us to make this change in a much easier way...

We just started block selection mode by using the short-cut Alt+Shift+A. Than we were able to select all lines in front of my source code as shown in the following screenshot.

After that we added my APPEND ' in front of each source code line in one shot...

... and did the same with ' TO SOURCE_CODE. at the end of each source code line.

Done! In this situation this saved us a lot of time, because we had to do it not just for one test!

Maybe it will save you some time in the future, too!

P.S.: To disable block selection mode you just press the short-cut Alt+Shift+A, again.

11 Comments
Former Member
0 Kudos

For those unaware, this is how to do it in New ABAP Editor.

Method 1: Using regular expression and replace in selection.

(.*) means select entire line, $1 in replace means insert the found text.

Method 2: Block selection using ALT + MouseDrag

Type append ' and use Ctrl+D to duplicate lines.

Alt+MouseDrag to block select the text to be inserted.

Drag the selected text to where it needs to be inserted (start of line 8).

adrianos_campanhola
Participant
0 Kudos

I had to login just to say: Thank you! I always forget that the regular expression exists in the search feature, and when I do, I have a lot of trouble using it 😃

gerald_roux2
Explorer
0 Kudos

Nice one Michael, this is a feature I've missed a few times after moving to AiE.  Thanks for sharing :smile:

schneidermic0
Advisor
Advisor
0 Kudos

Hi Manish,

Thanks for sharing! I just forgot this...

This will help me when I have to fix something in old releases... :smile:

Michael

ChristianGünter
Contributor
0 Kudos

Additon to Method 2:

You can do this directly by marking lines via ALT + Shift + UP/Down and then typing append '.

I think multiple cursors are one of the most useful and little-known features in the New ABAP Editor. Once you know it, it can really boost your productivity.

Regards Christian

Former Member
0 Kudos

I am on SAP Logon 720. Which SAP GUI version are you using?

Alt Mousedrag is same as Alt Shift up/down.

When I type something after selecting multiple lines, it gets inserted only at first line of block, not all.

adrianos_campanhola
Participant
0 Kudos

AFAIK(or remember) this was made avaiable on Sap Gui 7.30 Patch level 4

ChristianGünter
Contributor
0 Kudos

I'm on SAG Gui 7.30 Pl 8. Can't remember when it was introduced.


Alt Mousedrag is same as Alt Shift up/down.


Yes, of course. Key point is that you can type in multiple lines with this technique.

former_member182889
Active Participant
0 Kudos

Thanks for sharing!

I'm a huge fanboy of the hidden gems of the ABAP-editor and as such I got to love the ALT + Mousedrag a lot. Missing this feature in AiE hurt - up to now. Though in one aspect the AiE Editor behaves differently: I used the block selection particularly in order to align e. g. data-declarations for multiple rows. When using the TAB in AiE block selection this affects the whole line though (and not the block marked). Is there any setting I'm missing which changes this behaviour?

Cheers,

Oliver

schneidermic0
Advisor
Advisor
0 Kudos

Hi Oliver,

Unfortunately, this is not possible, currently.

At least I found an improvement request for Eclipse regarding this issue:

Bug 288430 [block selection] Shift Left/Right with Block Selection

Michael

joachimrees1
Active Contributor
0 Kudos
I knew this block-selection mode (Alt+Shift+A) yes, but after only asking internally - thanks @ Daniel!
But I think it's a bit 'clunky' in AdT - in the use case you describe, I'd probably still copy the source overt to notepad++, do the editing there and the copy it back.

The block mode in notepad++ it's just:
alt+mouse(clic+hold+drag)
or
alt+shift+arrow-keys.

-> With this 'hack', I especially like being able to do it without a mouse, #keyboardOnly.

best
Joachim
Labels in this area