vim tabs/spaces FAQ: How do I convert vi/vim tabs to spaces?
You can convert tabs to spaces in vim using the usual vim search and replace command. Specifically, this vim "tabs to spaces" command is all you need:
In short, this command can be read like this:
- From the first line to the last line (1,$)
- Swap each tab (\t) with two spaces (convert each tab to two spaces)
- Do this globally on each line, meaning that if there is more than one tab on any line, make sure you convert all of them.
Regarding that last line, if you really just want to convert the first tab on each line to spaces, just use the same command, but omit the 'g' at the end, like this:
That's all you need to convert tabs to spaces in vim.