Getting cool auto-indent in vim

Usually, I think there are better ways to write code today but often vim is simply useful because you are on an ssh connection or in a virtual environment or whatever.

Anyway, to get the IMHO quite cool auto-indent feature when pressing
“Tab” like emacs does, simply put this in your .vimrc:


set cindent
set smartindent
set autoindent
set expandtab
set tabstop=2
set shiftwidth=2
set cinkeys=0{,0},:,0#,!,!^F

Of course you can read more about the vim indenting feature in the documentation. Of course, I think most of you will know that already, so this entry is more a reminder for me.

[EDIT] uws remindend me, that the first three lines were missing. Seems the default on my system already included them. Thanks!

Commentary

Leave a response »

  1. 1. November 12th, 2006

    I think it’s better to leave tabstop at its default value and set softtabstop=2 instead.

Trackbacks

Leave a comment, a trackback from your own site or subscribe to an RSS feed for this entry. Trackback URL for this entry Comments feed for this entry

Leave a response

Leave a URL

Preview