12-19-2016 10:23 AM
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.
12-19-2016 10:34 AM
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.
12-22-2016 3:13 PM
09-02-2022 10:01 AM
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.
12-19-2016 10:47 AM
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
12-19-2016 4:38 PM
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.
12-19-2016 7:29 PM
12-19-2016 9:11 PM
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.
12-19-2016 9:24 PM
If it only worked on new/modified code then it wouldn't be very pretty IMHO.
12-22-2016 11:04 AM
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
12-22-2016 3:13 PM
IMHO Pretty Printer doesn't make code pretty......Indents should be to next word! <grrr>