converting tabs to spaces in vi

Posted by: barbara | Date: Nov 06, 2008 | Category: mac os x python
This is mostly for my own personal reference - just one of those little things I use frequently and always forget how to set up:

If you're writing Python, then you know that indentation is, uhm, somewhat important. Mkay. I use four space indentation as a standard, but it's kind of a pain with vim, and my space bar is wearing out (one more reason to keep things nice and DRY though).

Anyway, to save myself a few keystrokes and a lot of aggravation, I just added a line to my vimrc:
sudo vi /usr/share/vim/vimrc
set softtabstop=4
Now hitting the tab key inside any file will indent four spaces. Simple but useful.

Justin Lilly - 2008-11-08 00:22:52

I also have a function that does it too. map ,ft :%s/ / /g<CR> " replace all tabs with 4 spaces for files you didn't write to start :)

Foobar - 2008-11-09 10:51:18

Justin, :help retab does exactly that