On-demand was what I had in mind. In essence, the user would select the code block they wished to format. The autoformat code would be applied to that part as though the user had just started typing it. If the user made every choice, the entire file would be automatically formatted.