othree / html5.vim

HTML5 omnicomplete and syntax
http://www.vim.org/scripts/script.php?script_id=3236
934 stars 76 forks source link

Conditional comment blocks get indented inconveniently #13

Closed shazow closed 13 years ago

shazow commented 13 years ago

Example, from the HTML5 boilerplate:

<!doctype html>
<!--[if lt IE 7 ]> <html class="no-js ie6" lang="en"> <![endif]-->
<!--[if IE 7 ]>    <html class="no-js ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]>    <html class="no-js ie8" lang="en"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--> <html class="no-js" lang="en"> <!--<![endif]--> 
<head>

When I re-indent it with gg=G, it ends up looking like this:

<!doctype html>
<!--[if lt IE 7 ]> <html class="no-js ie6" lang="en"> <![endif]-->
    <!--[if IE 7 ]>    <html class="no-js ie7" lang="en"> <![endif]-->
        <!--[if IE 8 ]>    <html class="no-js ie8" lang="en"> <![endif]-->
            <!--[if (gte IE 9)|!(IE)]><!--> <html class="no-js" lang="en"> <!--<![endif]--> 
                <head>

This makes logical sense (since technically <html> is declared 4 times), but is not ideal. I propose a flag to ignore indents on lines starting with a comment (or bonus points if it's specific to conditional comments).

othree commented 13 years ago

We didn't parse the html document. So this is not easy to fix. I will keep this issue open until I get good solution to fix this.

othree commented 13 years ago

Use a simple fix only for html and body tag