Skip to Content
0

Pretty printer for Modified code only

Dec 19, 2016 at 10:23 AM

383

avatar image

It's generally not a good practice to use pretty printer on existing code. However, it would be really nice if Pretty printer can be used and only new/modified code is formatted. Old code remains as it is. Is there a way to do so?

I tried to search for such an SAP note before asking the question here. Could not find any helpful note.

10 |10000 characters needed characters left characters exceeded

If it only worked on new/modified code then it wouldn't be very pretty IMHO.

2

IMHO Pretty Printer doesn't make code pretty......Indents should be to next word! <grrr>

0
* Please Login or Register to Answer, Follow or Comment.

5 Answers

Kiran K Dec 19, 2016 at 10:34 AM
3

Gaurav,

"It's generally not a good practice to use pretty printer on existing code".

It is indeed a good practice to use Pretty printer irrespective of whether it is a new code or existing code.If a developer hasn't used it previously then we need to set it right by using it now.If you are worrying about the version management differences then you can check "ignore upper/lower case" checkbox in the comparision options of version management.Pretty printer is a nice feature whose usage should be encouraged and not skipped.

K.Kiran.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

No you don't.

0
Florian Henninger
Dec 19, 2016 at 07:29 PM
0

It isn't an option to just pretty print your modified part. Within eclipse you may be able to write an extension which will be able to do so, but I think that is a very high effort for such a small use case.

Sorry, but the short answer is "no" :-(

~Florian

Share
10 |10000 characters needed characters left characters exceeded
Iftah Peretz
Dec 19, 2016 at 09:11 PM
0

Hi,

I know you said no work around, but as you already know by now - that's the only choice you've got :)

So I would suggest writing your code on some local object ZTEST kind of program and format your code there and then copy and paste it back to where you need to be.

Another option is to write your code in a method/subroutine/function that is in a separate include (of which you can pretty format) thus reducing your code to a single line in the altered code.

Share
10 |10000 characters needed characters left characters exceeded
Gaurav Kaneria Dec 19, 2016 at 10:47 AM
0

Hi Kiran,

Thanks for your response.

I am aware of ignoring cases and indentations. What if that is not an option?

Is there a way to make sure that pretty printer works only for the newly added code? Not looking for any work around.

Regards,

GK

Show 1 Share
10 |10000 characters needed characters left characters exceeded

No. You have two ways of pretty printer: the classic "pretty printer" button (whole code), and context menu in the dynpro-based ABAP editor "Format selection" to pretty print the selected text, but this is different from the classic pretty printer, with no formatting option. I don't know whether there are other options in Eclipse.

0
Suhas Saha
Dec 22, 2016 at 11:04 AM
0

Hello Gaurav,

Actually there is an option in Eclipse - Format Block(Ctrl+Shift+F1) which you can use to format the selected text.

I am not sure if this is what you are looking for?

@Sandra:

"context menu in the dynpro-based ABAP editor "Format selection" to pretty print the selected text" - Tbh, i did not know such a feature existed in the GUI Editor.

"but this is different from the classic pretty printer, with no formatting option" - What do you mean by this? Screenshots, maybe :-)

BR,

Suhas


Share
10 |10000 characters needed characters left characters exceeded