vi ~/.vimrc
To get vim to interpret tab as an “indent” command instead of an insert-a-tab command, do this:
set softtabstop=2
To set the mod-N indentation used when you hit the tab key in vim (what Emacs calls c-basic-offset), do this:
set shiftwidth=2
To cause the TAB file-character to be displayed as mod-N in vi and vim (what Emacs calls tab-width), do this:
set tabstop=4
To cause TAB characters to not be used in the file for compression, and for only spaces to be used (what emacs calls indent-tabs-mode), do this:
set expandtab
In vi (and vim), you can do this stuff on a per-file basis using “modelines,” magic comments at the top of the file, similarly to how it works in Emacs:
/* ex: set tabstop=8 expandtab: */