In most cases, I want to use tabstop=4
while editing files. But for some types of file, like xml file, I want to use tabstop=2
.
I added
au filetypedetect FileType xml,html,xhtml,javascript set tabstop=2 softtabstop=2 shiftwidth=2
in my .vimrc
file. It works if I am editing only one file. But if I am editing multiple files, it cannot set the tab stops correctly for all the buffers. It seems the file type is detected and set only on startup, and never change since.
I want the FileType
set each time I switch the buffer. How can I do that?