vim smartcase is Vim's built-in semi-insensitive case matching

To update (replacing the current version) run webi vim-smartcase.

Files

These are the files / directories that are created and/or modified with this install:

~/.vimrc
~/.vim/plugins/smartcase.vim

Cheat Sheet

Vim search /foo is case-sensitive by default, but comes with options for swapping that to be:

  1. case-insensitive by default - i.e. /foo\c
  2. and case-sensitive on mixed-case search - i.e. /Foo\C

This vim-smartcase plugin adds set ignorecase and set smartcase to your ~/.vimrc.

Case Sensitivity in Vim

" treat everything in text and search as lowercase
set ignorecase
" treat mixed case as case sensitive
" requires 'ignorecase' to work
set smartcase
" explicit case-insensitive search for 'Bar'
" (\c can go anywhere in the search)
/Bar\c
/\cBar
/Ba\cr
" explicit case-sensitive search for 'Bar'
" (\C can go anywhere in the search)
/Bar\C
/\CBar
/Ba\Cr

How to do this manually

Set ~/.vimrc:

" make searches case-insensitive by default (i.e. /foo\c)
:set ignorecase
" make mixed-case searches case-sensitive by default  (i.e. /Foo\C)
:set smartcase

" fyi: you can put \c or \C before, after, or in the middle of a search
" ex: /Bar\c or /\cBar or /B\car

Available at https://github.com/webinstall/webi-installers/blob/master/vim-smartcase/smartcase.vim

Contribute

Report an Issue Submit Installer Star on GitHub