开发者

How can i indent my html file with vim correctly?

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

  set tabstop=2
  set开发者_StackOverflow中文版 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


It works out of the box for me. Try if it works with the minimal setup:

$ vim -u NONE
:set nocp
:filetype indent on
:set ft=html

and type in some HTML code.

The second tag should be indented by a tab now.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜