如何在 VI 中整理 HTML 文件的缩进? [英] How do I tidy up an HTML file's indentation in VI?

查看:22
本文介绍了如何在 VI 中整理 HTML 文件的缩进?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何修复他的巨大 html 文件的缩进,这些文件都搞砸了?

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

我尝试了通常的 "gg=G 命令,这是我用来修复代码文件缩进的.但是,它似乎不适用于 HTML 文件.它只是删除了所有格式.

I tried the usual "gg=G command, which is what I use to fix the indentation of code files. However, it didn't seem to work right on HTML files. It simply removed all the formatting.

我还尝试设置 :filetype = xml,看看是否欺骗它认为这是一个 XML 文件会有所帮助,但它仍然没有做到.

I also tried setting :filetype = xml, to see if tricking it into thinking this was an XML file would help but it still didn't do it.

推荐答案

在我的 .vimrc 中使用 filetype indent on,Vim 可以很好地缩进 HTML 文件.

With filetype indent on inside my .vimrc, Vim indents HTML files quite nicely.

shiftwidth 为 2 的简单示例:

Simple example with a shiftwidth of 2:

<html>
  <body>
    <p>
    text
    </p>
  </body>
</html>

这篇关于如何在 VI 中整理 HTML 文件的缩进?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆