How do I fix the indentation of an entire file in Vi?

前端 未结 16 2254
不知归路
不知归路 2020-12-02 03:24

In Vim, what is the command to correct the indentation of all the lines?

Often times I\'ll copy and paste code into a remote terminal and have the whole thing messed

16条回答
  •  囚心锁ツ
    2020-12-02 03:51

    For XML files, I use this command

    :1,$!xmllint --format --recover - 2>/dev/null
    

    You need to have xmllint installed (package libxml2-utils)

    (Source : http://ku1ik.com/2011/09/08/formatting-xml-in-vim-with-indent-command.html )

提交回复
热议问题