# Configure Vim to use spaces instead of tab

Jan 07 2012 Published under Linux,Programming | Tags:

Spaces are preferred over tab character in coding indentation to ensure indentation consistency. As different editors may use different indentation for tab character, using spaces ensures the indentation of the code to be consistent.
To configure vim to use spaces instead of tab for indentation, create a .vimrc in home folder with the following settings:

:set shiftwidth=2
:set tabstop=2
:set expandtab
:set cindent


:help C-indenting


in vim

other related command:

:retab  //to change all the existing tab characters to match the current tab settings

Tags:

Comments are closed at this time.