Custom high performance search engine development contract or hire by Kevin Duraj Tel: (310) 774-948

VIM replace tab for spaces

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: */

Leave a Reply

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>