I'm trying to get vim to indent using tabs for python files. I don't want a discussion about the merits of tabs vs spaces, I just want tabs. In my vimrc, I not only have
set shiftwidth=4
set tabstop
but I also have some python specific settings:
augroup python_files
autocmd!
autocmd FileType python setlocal noexpandtab
autocmd FileType Python set tabstop=4
autocmd FileType Python set shiftwidth=4
augroup END
This seems like it should correctly set my indentation settings in python files but when I open one, it shows literal tabs as 8 characters wide and the TAB key inserts 4 spaces. Is there something else that I could be doing here?
I just figured it out. In my augroup
, I was using a capital "P" in Python, when it should be lowercase. This following works perfectly:
augroup python_files
autocmd!
autocmd FileType python setlocal noexpandtab
autocmd FileType python set tabstop=4
autocmd FileType python set shiftwidth=4
augroup END
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