Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Pretty printer for Modified code only

Former Member
0 Likes
5,606

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 REPLIES 10
Read only

kiran_k8
Active Contributor
3,745

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.

Read only

Former Member
0 Likes
3,745

No you don't.

Read only

0 Likes
3,745

In a semi-perfect world, all code would look the same.

In a perfect world, all code would always look as how the respective reader would like to see it or tends to understand it best.

In reality there are code styling conventions which do not align with the hard coded (?) pretty printer. And in exactly those cases it makes sense to not de-prettify your old code only because of some new code.

Read only

Former Member
0 Likes
3,745

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

Read only

0 Likes
3,745

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.

Read only

Florian
SAP Champion
SAP Champion
3,745

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

Read only

iftah_peretz
Active Contributor
3,745

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.

Read only

Jelena_Perfiljeva
Active Contributor
3,745

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

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
3,745

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

Read only

Former Member
0 Likes
3,745

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