vim-lister icon indicating copy to clipboard operation
vim-lister copied to clipboard

Feature Request: smartcase option

Open Konfekt opened this issue 6 years ago • 3 comments

How about an option to grep using smartcase by default, instead of case-sensitively?

Right now, prepending \C whenever the searched expression does not contain an upper case letter is the only, inconvenient, workaround.

Konfekt avatar Oct 31 '18 20:10 Konfekt

Hey there!

This might be a bit challenging. Internally, the :Xgrep family of commands are using the comparison operators =~# and !~# to do the list grepping. These operators always act like 'ignorecase' is off. I could (arguably should) change these to =~ and !~ to respect the 'ignorecase' option. There seem to be no operators, however, that respect 'smartcase'. Same goes for functions like match().

A workaround may be to implement a custom comparison function that duplicates the 'smartcase' behaviour, but I hesitate to do so in case of various nuances that I may miss.

tommcdo avatar Dec 05 '18 18:12 tommcdo

True, I also would say that to reproduce smart-case, one must

  1. stick to =~# and !~#,
  2. check if &ignorecase is set, if so prepend \c to it, except if &smartcase is set and the string contains an upper case character.

Konfekt avatar Dec 05 '18 20:12 Konfekt

Better, use =~ and !~, and prepend \C to the string if &smartcase is set and the string contains an uppercase letter.

Konfekt avatar Dec 06 '18 12:12 Konfekt