How to store Vim tabstop settings in the file

vim

I need different tab widths for different files when using Vim. Is there a way to store this information in the file, and let Vim apply the setting automatically?

Best Answer

Depending on what fits your situation you could look into customizing the filetype plugins (if you want tabstop settings by filetype) or enable modelines and accept the accompanying security risks if the settings are specific to individual files.

For the filetype approach, as an example I have the following in ~/.vim/after/ftplugin/python.vim:

setlocal expandtab softtabstop=4 shiftwidth=4
Related Question