say that i have a project wh开发者_如何学运维ich lies in a folder called 'bin', and i want some specific vim configuration automatically loaded when i edit any file inside the project folder. how can i do that?
I think what you want is an autocommand. Perhaps something like this:
autocmd BufRead,BufNewFile ~/bin/* call SetBinOptions()
function SetBinOptions() {
setlocal number
setlocal nowrap
...
}
If you need to do something complex with the path matching, you can take a slightly different approach, making the decision about whether to apply the options within the function. Suppose you had some regex the path had to match:
autocmd BufRead,BufNewFile * call SetCustomOptions()
function SetCustomOptions() {
if (match(expand("%:p"), /regex/) {
setlocal number
setlocal nowrap
...
}
}
Using set exrc
helped me. See http://damien.lespiau.name/blog/2009/03/18/per-project-vimrc/
I use "set exrc" in ~/.exrc and a local .exrc in the directory.
精彩评论