Is there a text editor that will "pretty print" for display without changing the underlying text?
Asked Answered
D

0

1

There are two competing requirements

1) I want to pretty print so that I can read and understand code written by my peers

2) I don't want to check in the pretty printed code to source control because...

  • It might not meet the coding standard where I work
  • When reviewing history in source control, formatting changes obscure the 'real' changes.

For discussion of problems checking in formatting changes, see this other stackoverflow question

At the same time, I still need to be able to edit the file and save changes. I want to be able to edit the ugly text while I see the pretty text.

Does anyone know an editor with a feature like this?

Dragrope answered 10/9, 2011 at 15:52 Comment(3)
Pretty much impossible, I'd say. Where should the artificial intelligence come from that converts your (pretty) editing to uglified code? How should an editor infer an "ugly style" from some file it reads? If both styles, ugly and pretty, cannot be specified as indent profiles, you're SOL.Leeward
I think it is pretty straight forward actually. We already have pretty printers that take ugly code and make it better. We already have format as you type that knows how to indent whenever inserting a newline. And we have plenty of cases where data is different from display. Take html for example. So we do two things...Dragrope
So we do three things... 1) Display the pretty printed result w/o changing the underlying data. 2) Data editing operates on the ugly data - not on the pretty display. Auto-indenting etc. operates on the ugly data. 3) Some mapping so mouse clicks in the pretty display go to the right place in the ugly data.Dragrope

© 2022 - 2024 — McMap. All rights reserved.