Tuesday, January 17, 2012

Re: setting global options from a modeline

On 2012-01-17, Radu Grigore wrote:
> Is it possible to set the global version of an option using a modeline?

I don't think so. ":help modeline-local" says:

The options are set like with ":setlocal": The new value only
applies to the buffer and window that contain the file.
Although it's possible to set global options from a modeline,
this is unusual.

Setting a global option is not the same thing as setting the global
value of an option.

> My use-case is the following: Whenever I work on a certain project, I want to
> have certain settings. I do not want these settings when I work on other
> projects, and I do not want to write modelines in every file of the project.
> So, you may very well ask, how do I define a project? Well, whenever I work on
> it I tend to start by running
> vim TODO
> This is why I thought about using a modeline in the file TODO. I could also
> identify the project by its directory name, I guess, although this seems
> frailer.

You could use autocommands such as these in your .vimrc to set
whatever options you want.

au BufRead TODO set option1=value1 option2=value2
au BufRead /path/to/project/** setlocal option1=value1 option2=value2

The first sets the global values of options whenever TODO is opened;
the second sets the local values of options for any file opened
under /path/to/project.

HTH,
Gary

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: