How to automatically set the number of indented spaces based on the file name suffix in vim?

problem description

just entering VIM, I want 4 indented spaces when editing * .php files, but 2 indented spaces when editing * .blade.php files.
currently sets the number of spaces according to Filetype, but this setting does not meet my needs.

ask for help

wants to be able to set the number of indented spaces by matching the file name suffix to find a configuration or a plug-in. TKS~

Dec.05,2021

autocmd has a BufEnter event that can be used to execute commands. You can follow this line of thinking to search.

in addition, the width of characters occupied by tab when indenting can be adjusted by parameters such as tabstop softtabstop.

I won't give you the configuration, but I hope you can learn more about vim,. Otherwise, you will feel lost everywhere in the process of using it, and you will abandon the pit immediately.

if you want to quickly learn the use of vim, I recommend you take a look at vim practical skills this book

Menu