Vim has a "smartcase" feature, which makes searching case insensitive, but only if the search contains all lowercase letters. When you search on any uppercase letters, smartcase assumes you want a case sensitive search. Is there a way to get the same behavior in zsh's tab completion?
Asked
Active
Viewed 2,417 times
1 Answers
14
Take a look at my zshrc file.
https://github.com/martincanaval/arch-conf/tree/master/etc/zsh
I have that functionality you are asking for and I believe this line made it.
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'

lmcanavals
- 2,339
- 1
- 24
- 35
-
Brilliant. I had `m:{a-zA-Z}={A-Za-z}` that I'd copied from somewhere, and I just replaced it with that. Interesting note, the exact meaning smartcase in Vim is that the entire string is case-sensitive if it contains any uppercase letters. In this zsh variant, only the uppercase letters within the string are case-sensitive. I think I actually like this way better. – Jack O'Connor Jan 17 '13 at 20:39
-
Oh, the credit isn't mine, I took that (and most of my .zshrc) from the [grml zsh site](http://grml.org/zsh/). Glad it helped. – lmcanavals Jan 17 '13 at 21:07
-
I find that only adding this command does not work. After that, we have to use `autoload -U compinit && compinit` to make case-insensitive completion work. – jdhao Oct 09 '19 at 03:54
-
Did your github repository go somewhere else, the link is dead? – Anthon Feb 09 '20 at 10:51
-
2`zstyle ':completion:*' matcher-list '' '+m:{a-zA-Z}={A-Za-z}' '+r:|[._-]=* r:|=*' '+l:|=* r:|=*'` is more allowing. – HappyFace Jul 21 '20 at 08:33
-
@HappyFace `zstyle ':completion:*' matcher-list '' '+m:{a-zA-Z}={A-Za-z}' '+r:|[._-]=* r:|=*' '+l:|=* r:|=*'` is incorrect: depending on what one has in the directory, the case of characters already typed is not always corrected to the right ones, giving a nonexistent file name. – vinc17 Dec 15 '22 at 15:27