How to provide different indentation widths for different code files in vim?

  question, vim

May I ask how to set different tab space widths for different code files in the. vimrc file (which can be judged by the suffix name briefly)? For example, the tab of an. rb file is indented by two spaces at a time, the. C file is indented by three spaces, and the. cs file is indented by four spaces, similar to this. PS: It only needs to be used in linux and OS X. Thanks to all the friends who provided the answers.

According to the file type to set it, as follows.

"Set different numbers of spaces for different file types to replace TAB
 autocmd FileType php,python,c,java,perl,shell,bash,vim,ruby,cpp set ai
 autocmd FileType php,python,c,java,perl,shell,bash,vim,ruby,cpp set sw=4
 autocmd FileType php,python,c,java,perl,shell,bash,vim,ruby,cpp set ts=4
 autocmd FileType php,python,c,java,perl,shell,bash,vim,ruby,cpp set sts=4
 autocmd FileType javascript,html,css,xml set ai
 autocmd FileType javascript,html,css,xml set sw=2
 autocmd FileType javascript,html,css,xml set ts=2
 autocmd FileType javascript,html,css,xml set sts=2