vim - tab awareness

1

1

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?

Hamish

Posted 2011-03-28T03:49:28.927

Reputation: 547

Answers

2

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.

Heptite

Posted 2011-03-28T03:49:28.927

Reputation: 16 267