Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a HTML like this:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Index - feedman</title>
   <link rel="stylesheet" href="/media/bluetrip/css/screen.css" type="text/css" 
media="screen, projection">
    <div class="container">
<div id="greeting">
{% if request.user.is_anonymous() %}
<a href="{{ create_login_url() }}">login</a>
{% else %}
Hello {{ request.user }}! <a href="{{ create_logout_url() }}">logout</a>
{% endif %}

{{ message }}

How should I automatically format with proper indentation using VIM?

share|improve this question

Perhaps you could try : gg=G to indent all the document ? I'm not sure it works good with HTML.

share|improve this answer
Works for me. .... – innaM Oct 22 '09 at 11:16
Since I didn't have the file saved, I first had to use :set filetype=html – chocojosh May 25 '11 at 15:49
Works brilliantly, I didn't know about the = command to autoindent. You can use to add support for HTML5 elements. – Liam Newmarch Jul 18 '12 at 15:43

try to use tidy as explained in the vim tips wiki:

exe 'setlocal equalprg=tidy -quiet -f '.&errorfile

setlocal makeprg=tidy -quiet -e %

share|improve this answer
No tidy please; I wonder if VIM supports this feature at all (that Emacs already has) – Sridhar Ratnakumar Oct 22 '09 at 10:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.