Can grep in vim be made to be conditionally case sensitive?

When I do a in-document search with / or ? it only performs a case sensitive search when a capital letter appears in the search pattern because of the combination of the ignorecase and smartcase settings. Is there a way to mimic this behavior with the :grep command without needing to manually add the -i setting manually every time?

4

1 Answer

You may be interested in looking at :vimgrep which can use Vim's regular expressions for pattern matching. This includes honoring 'ignorecase' and its related options, unless you explicitly state otherwise. Specifically, if a "\c" appears in a pattern it makes the pattern ignore case, and "\C" forces case matching. Look at:

:help :vimgrep
:help /\c

(Yes, the forward- and back-slash are meant to be part of the :help command.)

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like