HTML indent settings in Vim

Despite not agree­ing with all of it, “Just Use Sub­lime Text” (an invec­tive against Vim — or, more accu­rate­ly, against rec­om­mend­ing Vim to any­one who isn’t already indoc­tri­nat­ed by it) by Andrew Ray is an inter­est­ing read. The sec­tion deal­ing with indent­ing in par­tic­u­lar struck a chord with me:

Paste this into an emp­ty buffer:


:set ft=html and then gg=G. Let me know what you get. In all seri­ous­ness, nev­er, ever tell me what you get.

As I said in a tweet, what I got didn’t offend me too much. But many peo­ple would argue that the <span> tag should be indent­ed inside the <p> tag. I’d prob­a­bly do this myself, actu­al­ly — and there have been aspects of Vim’s indent­ing that irk me. So I set about find­ing a solu­tion.

Con­tin­ue →