How can I include vim settings in source code so that the file is displayed the same way?

I vaguely remember that there is a way to store instructions for vim in my file (like tabstop width etc). I'm not speaking of settings in vimrc but of storing those settings with in the file to be edited.

That way the tabstop has always the right width even if I transfer this file to another computer.

However, I can't remember what the magic word is so that vim picks up those settings when loading the file. Any ideas?


Solution 1:

Put a comment with vi: in it, ending with a newline.

/* vi: tabstop=4
*/

If vim doesn't pick this up then you may need to add set modeline to ~/.vimrc. See :h modeline for full details.