Just in case my answer will get you going a little quicker (because I've
always found vim help useful, but it's a lot more useful to those who
already know--I've scratched my head and had to experiment a lot for
even simple things)...
You can put these modelines at the top of your file or the bottom. Also,
they can go on other lines, but I think there's a limit there and yet
another setting to change how tolerant Vim is in looking for them, but
as this approach suits me, I haven't experimented a lot to find any more
out. I think the limit may actually allow by default for the first two
lines, so your own example would work fine. In fact, I think I once
tried line 2 of my C file and it worked, but I can't guarantee it.
Here is what I put as the first line in my own C files to enforce how I
want them to behave versus the usual settings at my workplace:
/* vim: set tabstop=3 shiftwidth=3 noexpandtab: */
And here's what I put as the last line in my own HTML files:
<!-- vim: set tabstop=2 shiftwidth=2 noexpandtab: -->
You see that pretty well anything you can do on the ex command line in
Vim (:set ignorecase, etc.), you can put in these modelines. Very useful
feature indeed and salvation for me personally since I work in so many
different environments.
Hope this helps.
Best regards,
Russ Bateman
Aaron Johnson wrote:
List,
How can I include vim settings in the files I'm editing? For example,
if system wide I have syntax highlighting disabled but I want to
enable it just for one particular file. For c code I'd like to be able
to include something like this:
/*
* ?:syntax on
*/
It would have to always always be commented obviously, and the '?:'
would trigger reading those lines as vim options.
Any ideas if this is somehow supported by default or how to implement it?
Thanks.