You could modify
ignorecase when you move in or out of a window or buffer, so it will always have the desired value.
Automatically by file type
autocmd WinEnter * let &ignorecase = match( bufname("%"), '\.php$' ) != -1
autocmd BufEnter * let &ignorecase = match( bufname("%"), '\.php$' ) != -1
This would set
*.php files, and unset it otherwise.
You need to write the same command for both WinEnter and BufEnter, but they could call out to a function if you want to avoid repetition.
Manually set for each buffer (like setlocal)
Since you asked how to set
ignorecase locally, this solution might give you something close to what you wanted:
command SetLocalIgnoreCase set ignorecase | let b:ignorecase = 1
command SetLocalNoIgnoreCase set noignorecase | let b:ignorecase = 0
autocmd WinEnter * let &ignorecase = get(b:, 'ignorecase', 0)
autocmd BufEnter * let &ignorecase = get(b:, 'ignorecase', 0)
In the above,
b:ignorecase is a buffer-local variable, which the autocmds can pick up when switching focus. If you wanted window-local, use
get() to avoid errors in buffers where the variable does not exist, and default to
0 in that case.
(With liberal use of
eval this approach could even be generalised to other global options that you want to act as locals.)