[ACCEPTED]-How can I toggle smartcase in Vim?-vim

Accepted answer
Score: 21

If you want to toggle if off completely, just 3 do

:set nosmartcase

But if you want to toggle the mode of 2 one-two searches, use special symbols in 1 your search patterns:

  • \c makes the pattern ignore case, for example: /iGnOrEcAsE\c (matches "ignorecase");
  • \C makes the pattern match case, for example: /matchcase\C (doesn't march "MatchCase").
Score: 20

If you add a bang after the option name 7 in the set command, like this:

:set smartcase!

...it will toggle the 6 option. You can create a key mapping to 5 do this:

:map \s :set smartcase!<CR>

<CR> stands for carriage return. It 4 represents the Return key.

Now just press \s and 3 it toggles.

I usually write the mapping to 2 also show in the bottom line whether the 1 option is on or off, like this:

:map \s :set smartcase!<CR>:set smartcase?<CR>

More Related questions