Which vim options should be used in modelines?

264 views Asked by At

I'm wondering which vim options should I be specifying in modelines in my source files (mostly C), and which should not be specified there and rather left for the user to specify.

I believe that the modelines should enforce code-specific policies and/or help vim with the code, while avoiding interfering with user preferences if possible.

When answering, please explain why you believe that a particular option should be enforced via modeline, or not.

1

There are 1 answers

0
Michał Górny On

Right now, I find the following options useful:

  • ft to ensure that vim recognizes the file format correctly,
  • noet and sts=0 to disable expanding tabs into spaces (project coding style),
  • or alternatively et, ts, sts and sw to enforce project-specific tab expansion,
  • maybe tw to suggest line wrapping (but I wouldn't be so sure about that as it is a bit intrusive),
  • fenc to indicate the character encoding.

And those are the options I believe I shouldn't be setting:

  • ts if the project uses tab-indent — I believe that the user should be able to choose his own tab width,
  • folding — user preference,
  • indenting — user may have a preferred way of doing indents and changing that may actually cause extra or missing indent out of habit,
  • ff because vim should deduce the newline format correctly and if some software (like VCS) transparently converts the file, ff will actually break it.