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

前端 未结 16 2248
不知归路
不知归路 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 04:02

    You can create a mapping to do this for you.

    This one will auto indent the whole file and still keep your cursor in the position you are:

    nmap ai mzgg=G`z
    

提交回复
热议问题