Let's say you want to make use of ignorecase
as that's what you'd like when searching with /
and ?
. However you then realise how oddly pervasive this setting is in that is applies to things like :s
. Rather than inserting "\C" into every pattern you think you'll use use an autocmd and so some up with something like the following config.
set ignorecase
autocmd CmdLineEnter : set noignorecase
autocmd CmdLineLeave : set ignorecase
Only to find it doesn't work, ignorecase
still seems to be in effect when using :s
. This is because CmdLineLeave
fires not only before you truly leave the command-line but also before the command has executed.
Here's a snippet to overcome this in a generic fashion by using a timer.
let [s:ignorecase, s:smartcase] = [&ignorecase, &smartcase]
function! s:RestoreCase(ID)
let [&ignorecase, &smartcase] = [s:ignorecase, s:smartcase]
endfunction
augroup SaneCase
autocmd!
autocmd CmdlineEnter : set noignorecase nosmartcase
autocmd CmdlineLeave : call timer_start(100, '<SID>RestoreCase')
augroup END
The far reaching effecting of ignorecase
annoys me enough as it is but CmdLineLeave
firing before executing the command really takes the biscuit here.