Tuesday, January 17, 2012

Re: setting global options from a modeline

On Jan 17, 5:26 am, Radu Grigore <radugrig...@gmail.com> wrote:
> Is it possible to set the global version of an option using a modeline?
>

No. But, you could use an autocmd if you're not worried about security
to source a specific Vim script based on current directory or file
name or something when launching Vim or reading a file.

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

I understand the project.vim plugin allows project-specific settings
in some way...I think it sets Vim up to try reading project-
specific .vimrc files, but I'm not sure.

> 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 include a line like:

local_vimrc: relative/path/to/config/file.vim

in your TODO file, with a BufRead autocmd to find such a line in the
last few or first few lines and source the file. But note, this opens
you up to exploits if you ever edit a TODO file from someone else.

--
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: