Set tabstop & shiftwidth for Specified Filetype Opened in Vim Buffer

March 30, 2013

I always use tabstop=4 and shiftwidth=4 in vim, but for html file and some other template filetypes i prefer value 2. And I use vim buffers to work with mutiple files. If I switch between html files and other file, I also want the tabstop value to be correct. One way to achieve this goal is just write down tabstop=4 in html syntax file(under syntax folder). But I just wanna keep these changes in my .vimrc. Then I write down