开发者

How do i fix the indents in my html/php files in vim?

I am (slowly) making the switch to vim. I have added some settings to my .vimrc file (:syntax enable, :fileype plugin on, autoindent, etc.). Everything works great except when I try to indent lines using >. It double indents:

<div>

----<p>this line was autoindented </p>

</div>

<div>

--------<p>this line was indented using the > key </p>

</div>

I am a bit of a vim noob. Any help is g开发者_如何学运维reatly appreciated.


Make sure both of the following are set in your .vimrc file

set tabstop=4
set shiftwidth=4


You need to set tabstop and shiftwidth to the desired size - add this to your .vimrc:

set tabstop=4
set shiftwidth=4
set expandtab

You can read up about it on the Vim wiki.

If you don't have expandtab set, add that too - it converts tabs to spaces. If you have a file that has mixed tabs and spaces, :retab will go through and convert everything to your current settings as well.

Your example seems odd, because autoindent should, as far as I know, take its setting from shiftwidth - so they should be the same. You are indenting the single line with >>, correct?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜