Re: Specifying vim options in the files being edited

2006-09-08 Thread Luc Hermitte
Hello,

* On Fri, Sep 08, 2006 at 04:27:54PM -0400, Jean-Rene David <[EMAIL PROTECTED]> 
wrote:
> * Russell Bateman [2006.09.08 15:30]:
> > 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. 
> 
> That's not true. You can only set options.

That's easily extensible. See


-- 
Luc Hermitte
http://hermitte.free.fr/vim/


Re: Specifying vim options in the files being edited

2006-09-08 Thread A.J.Mechelynck

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.





The problem with ":syntax on" is that it is global. You either enable or 
disable it for all files being edited in all windows.


One way to do it yet, would be to disable _all_ filetype checking for 
_all_ files (which would in effect disable not only syntax highlighting 
but filetype-plugins and filetype-related indenting too). This might or 
might not be what you want, but it is done with


:filetype off

It would mean that even with

:syntax on

in your vimrc, no syntax highlighting would happen because no files 
would get a nonempty 'filetype'.


Then you could set the 'syntax' option for just that file by means of a 
modeline, which for C source would typically be


/* vim: set syntax=c : */

(which allows a */ comment trailer on the same line) or

/*
 * vim: syntax=c
 */

(which doesn't) (see "help modeline") in one of the first or last 5 
lines of the file. With that modeline and the global ":syntax on", that 
particular file would get syntax highlighting even if filetype detection 
is off.



Best regards,
Tony.


Re: Specifying vim options in the files being edited

2006-09-08 Thread Charles E Campbell Jr

Russell Bateman wrote:



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. ..snip..



There's a setting, modelines, that vim uses.   By default, its 5, but 
you can change it in your <.vimrc>, for example.
Within "modelines" lines of either the beginning or the end of the file, 
vim will search for modelines.


 :he 'modelines'
 :he modelines

Regards,
Chip Campbell




Re: Specifying vim options in the files being edited

2006-09-08 Thread Jean-Rene David
* Russell Bateman [2006.09.08 15:30]:
> 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. 

That's not true. You can only set options.

Excerpt from :help modeline:

   No other commands than "set" are supported, for
   security reasons (somebody might create a
   Trojan horse text file with modelines).

-- 
JR


Re: Specifying vim options in the files being edited

2006-09-08 Thread Russell Bateman
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:

   

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.




RE: Specifying vim options in the files being edited

2006-09-08 Thread Steve Hall
From: "Aaron Johnson", Fri, September 08, 2006 1:32 pm
> 
> 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.

You want to use modelines:

  :help auto-setting
  :help modeline

-- 
Steve Hall  [ digitect dancingpaper com ]


Specifying vim options in the files being edited

2006-09-08 Thread Aaron Johnson

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.