Changing Tabs to Spaces in Vim

Boy oh boy, I certainly hate finding tabs in source files I have to work on. While tabs are easy to get rid of (usually automatically) in most modern IDE’s, I often find I have to work remotely on source files using Vi/Vim. Making sure all tabs have been converted to spaces is usually the first thing I do, when working with a new source base …

To convert all tabs to spaces within Vim, use the :retab command like so:
:set expandtab
:%retab

For more info, check out the Vim user documentation: Tabs and spaces section.

h u g h


About this entry