Home:ALL Converter>How can i indent my html file with vim correctly?

How can i indent my html file with vim correctly?

Ask Time:2010-11-27T22:15:46         Author:Julian Weimer

Json Formatter

I set up the indentation in my vimrc in the following way:

  set tabstop=2
  set shiftwidth=2

  set autoindent
  set indentexpr
  set expandtab

I created the indent folder in my ~/.vim/ directory and pasted an html indentation-plugin into ~/.vim/indent/ . I'm using the following one:

http://www.vim.org/scripts/script.php?script_id=2075

Whenever i try to "gg=G" in normal-mode it deletes all the indentation instead of indenting the file in a proper way. JavaScript files for example work nicely with another indentation plugin i have found, but nomatter which html plugin i have used so far, it didn't really work in a useful way.

Is there anything i can do here?

/////////////// Update: i just tried to change the filetype to xml and it began to work. Now i'm asking myself how i can get this to work with html files. Hope someone can help me out.

Heading

Author:Julian Weimer,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/4292056/how-can-i-indent-my-html-file-with-vim-correctly
yy