Indenting (tabbing) WP_head

Technically possibly, but probably not worth the effort (and overhead). If you inspect the source with something like Developer Tools in Chrome, your HTML will be automatically indented. In fact, some caching plugins (like W3 Total Cache) even remove all whitespace to improve page load times.

That said, if you want to ensure that your wp_head content is indented, you would need to do the following:

  1. Add a function to get_header which executes last. This function get all functions attached to wp_head (using $wp_filter['wp_head']), remove them, and reattach them to your own custom action (my_wp_head for example).
  2. A custom function (my_wp_head() for example) should then be attached to wp_head
  3. In the my_wp_head() function you would want to
    1. Create an array of match/replace regex patterns ($patterns = array("pattern"=>"replace pattern");). This pattern should trim whitespace and re-add tabs to the beginning of each line.
    2. Make a call to ob_start() to capture output
    3. Process the previous wp_head functions by calling do_action('my_wp_head')
    4. Process output with a call to echo preg_replace( array_keys($patterns), array_values($patterns), ob_get_clean() );