tags:

views:

70

answers:

2

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 greatly appreciated.

+2  A: 

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

set tabstop=4
set shiftwidth=4
Isaac
This fixed it. Thanks!
markle976
+1  A: 

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?

cincodenada
Nice! I didn't know about expandtab and :retab. And to answer your question - I am now. Thanks!
markle976