How to prevent CKEditor trim plain text in source view
CKEditor distinguishes Output formatting from Source Code formatting.

You're essentially wanting to do output formatting inside the source code formatting. It seems this is currently not possible.

From the documentation:


  Configuring Source Code Format
  
  At the moment the only aspect of the source code view that you can configure is the tab-size CSS property of the source editing area. Use the CKEDITOR.config.sourceAreaTabSize option to set the width of the tab character. Enter an integer to denote the number of spaces that the tab will contain.
  
  http://docs.ckeditor.com/#!/guide/dev_sourcearea


You might play with using the popup source editor instead of the inline editor, I don't know if this would give you any more possibilities to plug into and alter the HTML in source-editing mode or not.