vim, right way to indent css and js inside html

后端 未结 2 1160
抹茶落季
抹茶落季 2021-01-21 08:35

Couldn\'t find proper solution in old questions, so

    

    
        
          


        
相关标签:
2条回答
  • 2021-01-21 09:08

    I use othree/html5.vim plugin which supports css/javascript inside html. It works although this isn't probably the simplest solution.

    Your code is indented like this:

    <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="UTF-8">
        <title></title>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
        <style type="text/css">
          body, input{
            background-color:red;
          }
        </style>
        <script>
          function test() {
            return false
          }
        </script>
      </head>
      <body>
        <div></div>
      </body>
    </html>
    
    0 讨论(0)
  • 2021-01-21 09:08

    As it turns out: That this has been done on purpose! Even my current Vim 8.1 installation contains an indent/html.vim-file which has such zero-indentation as its default setting.

    That is however configurable via vimrc with:

    let g:html_indent_script1 = "inc" 
    let g:html_indent_style1 = "inc" 
    

    ...and -shame on us- is also mentioned in :help html-indent

    0 讨论(0)
提交回复
热议问题