vim Whitespace Convert tabs to spaces and spaces to tabs


You can convert tabs to spaces by doing the following:

First check that expandtab is switched off

:set noexpandtab



which replaces spaces of a certain length with tabs

If you enable expandtab again :set expandtab then and run the :retab! command then all the tabs becomes spaces.

If you want to do this for selected text then first select the text in visual mode.