Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 6 down vote accepted

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.

share|improve this answer
Thanks a lot for pointing me into the right direction! It works perfect. Cheers. – Jon Feb 15 '11 at 13:46
You can avoid having to have the closing comment string on a new line by using the "set" form of a modeline, for example: /* vi: set tabstop=4: */ – Heptite Aug 21 '11 at 20:05
I didn't need a new line # vim:et:sts=4:sw=4 – Felipe Alvarez Oct 2 '13 at 0:12
You're welcome: <!-- vi: set sw=4 ts=4: --> – Andrejs Cainikovs Feb 23 '14 at 16:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .