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?
vim Whitespace Convert tabs to spaces and spaces to tabs If you enable expandtab again :set expandtab then and run the :retab! command then all the tabs becomes spaces.
replace space by tab in vim you can do this: # first in . vimrc set up :set expandtab :set tabstop=4 # or you can do this :set tabstop=4 shiftwidth=4 expandtab # then in the py file in command mode, run :retab!
Use expand tab to convert new tabs to spaces 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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With