15

I believe there is a method to write a comment in a file that vim will use to override default tabbing and indent values.

Can someone point me to information about this feature and how to use it?

hakre
  • 193,403
  • 52
  • 435
  • 836
cmcginty
  • 113,384
  • 42
  • 163
  • 163

1 Answers1

19

Per-file settings can be done using "modeline magic".

The basic idea is that you can add a comment to an individual file like this:

/* vim: set tabstop=8:softtabstop=8:shiftwidth=8:noexpandtab */ 

Within vim, you should review:

Tim Henigan
  • 60,452
  • 11
  • 85
  • 78
  • thanks ... only leaving the */ on the same line gives me "E518: Unknown option: */" – cmcginty Apr 30 '10 at 02:43
  • Or you could just use a single-line comment! – Cascabel Apr 30 '10 at 03:00
  • Also not that vim will read vi modelines (good if you're changing vi compatible settings, not so useful for softtabstop etc.), and the abbreviated names work also, so you could have `/* vim: se ts=8:sts=8:sw=8:noet */` – Stephen P Sep 02 '10 at 00:29