How can you do a case insensitive search with line contexts displayed in vim while using the :g ex command?I tried the following but it doesn't seem to work...g/pattern/z#.1i|echo ================================I also tried this:g/pattern/iz#.1|echo ================================...but it results in an error.
Case Insensitive Search with g ex command?
ex mode;letter case
There are two ways to achieve this:One is to set ignorecase, then the pattern regex will ignore the case.  Yet, this solution is poor if you are writing a script that may need to be reused by someone.A better solution is to use the \c (ignore case) \C (do not ignore case) modifiers in the regex.  This command:g/\cpattern/z#.1|echo ================================Will always ignore the case of pattern no matter what you have set ignorecase to.And this command:g/\Cpattern/z#.1|echo ================================Will always perform a case sensitive search for pattern, even if you have ignorecase set to true.Reference (the forward slash is important)::help /ignorecase