Vim: Convert Tabs to Spaces
Tabs are evil. This guide will show you how to convert tabs to spaces in Vim.
Tabs are evil. This guide will show you how to convert tabs to spaces in Vim.
The expandtab property will ensure that when you hit tab it will actually use spaces. So first set the number of spaces a tab should be, then set expandtab.
set tabstop=2 shiftwidth=2 expandtab
Tabstop determines how many columns a tab counts for. Shiftwidth determines how many columns text is indented when using reindent operations. Expandtab is what actually uses spaces instead of tabs.
If you've got a file already full of tabs, converting to spaces is super easy. Make sure to follow step one first, then use retab.
Open the file and type:
:retab
This will fix all existing tabs.
Regardless if you’re the type of person who keeps a dozen or more tabs open or not, tab groups are a new feature of Google Chrome that can make your tabs more organized.