If I am writing code like this in vim:

 def my_function

and I hit enter, I would like the cursor to be positioned below the d.

Currently it is positioning the cursor as far left as possible.

How can I do this?

link|improve this question

50% accept rate
feedback

1 Answer

up vote 2 down vote accepted

There are several options you'll want to look at:

:help 'autoindent'
:help 'smartindent'
:help 'cindent'
:help :filetype-indent-on

(Those commands are typed exactly as you see them above.)

The 'autoindent' option will do as you describe, but Vim can be more intelligent about indenting, hence the others. Usually it's sufficient to use the last one only in your vimrc and let Vim detect your filetype and the proper indent option(s) to use for that filetype.

link|improve this answer
thanks heptite! – Hamish Mar 28 '11 at 21:04
feedback

Your Answer

 
or
required, but never shown

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