Replace tabs with spaces in vim
I would like to convert tab to spaces in gVim. I added the following line to my _vimrc
:
set tabstop=2
It works to stop at two spaces but it still looks like one tab key is inserted (I tried to use the h key to count spaces afterwards).
I'm not sure what should I do to make gVim convert tabs to spaces?
Solution 1:
Once you've got expandtab on as per the other answers, the extremely convenient way to convert existing files according to your new settings is:
:retab
It will work on the current buffer.
Solution 2:
IIRC, something like:
set tabstop=2 shiftwidth=2 expandtab
should do the trick. If you already have tabs, then follow it up with a nice global RE to replace them with double spaces.
If you already have tabs you want to replace,
:retab