Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I toggle smartcase in Vim?

Tags:

vim

I love smartcase, but there are times that I'd like to turn it off and search for just lowercase. Is there a builtin that will toggle smartcase, or do I need to write a function to toggle it?

like image 952
Drew Stephens Avatar asked Nov 20 '09 22:11

Drew Stephens


People also ask

What does Smartcase do in Vim?

Luckily, vim has the smartcase option that you can use TOGETHER with ignorecase. With both ignorecase and smartcase turned on, a search is case-insensitive if you enter the search string in ALL lower case. For example, searching for apple will find Apple and APPLE.

How to search in Vim case insensitive?

You can use in your vimrc those commands: set ignorecase - All your searches will be case insensitive. set smartcase - Your search will be case sensitive if it contains an uppercase letter.

Can you control F in Vim?

CTRL-F is a vital keystroke to control vim - it provides the page-down behavior and without that I have to find the actual page-down key which takes my fingers off the home row.


1 Answers

If you want to toggle if off completely, just do

:set nosmartcase

But if you want to toggle the mode of one-two searches, use special symbols in 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").
like image 56
P Shved Avatar answered Sep 30 '22 18:09

P Shved