Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .