Skip to Content

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.

blockSelectionMode.png

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.

blockSelectionInsert0.png

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.

blockSelectionInsert1.png

After that we added my APPEND ‘ in front of each source code line in one shot…

blockSelectionInsert2.png

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

blockSelectionInsert4.png

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.

To report this post you need to login first.

10 Comments

You must be Logged on to comment or reply to a post.

  1. Manish Kumar

    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).

    (0) 
    1. Christian Guenter

      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

      (0) 
      1. Manish Kumar

        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.

        (0) 
        1. Christian Guenter

          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.

          (0) 
  2. Oliver Jaegle

    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

    (0) 

Leave a Reply