How do I tidy up an HTML file's indentation in VI?

后端 未结 11 1883
庸人自扰
庸人自扰 2020-11-29 15:02

How do I fix the indentation of his huge html files which was all messed up?

I tried the usual \"gg=G command, which is what I use to fix the indentation of code fil

11条回答
  •  隐瞒了意图╮
    2020-11-29 15:48

    There's several things that all need to be in place. Just to summarize them all in one location:

    Set the following option:

    :filetype indent on
    :set filetype=html           # abbrev -  :set ft=html
    :set smartindent             # abbrev -  :set si
    

    Then either move the cursor to the top of the file and indent to the end: gg =G
    Or select the desired text to indent and hit = to indent it.

提交回复
热议问题