Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

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.

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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