This question already has an answer here:
I like to use tabs for indentation (hey, don't bully me!). But 33% of other programmers prefer spaces.
The norm with Python is to use spaces for indetation. Even so, I configured Vim to use tabs with Python since I recently worked on Python code that was indented with tabs. But right now I'm working on some other Python project which has spaces for indentation...
So now I want to make Vim figure out which kind of indentation the file uses and indent accordingly. So my question is how can I accomplish that?
I discovered the
copyindent option, which seems to solve the problem. But I am unsure whether this is the correct way to solve the problem. Does it have any pitfall? Is there a better way to do this?
For the sake of completeness, these are the contents of my
.vim/after/ftplugin/python.vim file, which is the one ensuring tabs are used for Python right now. I also have
filetype plugin indent on in my
setlocal tabstop=4 setlocal softtabstop=4 setlocal shiftwidth=4 setlocal textwidth=80 setlocal smarttab setlocal noexpandtab