How can I toggle smartcase in Vim?

前端 未结 2 1257
再見小時候
再見小時候 2021-02-07 11:10

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 w

2条回答
  •  囚心锁ツ
    2021-02-07 11:52

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

    :set smartcase!
    

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

    :map \s :set smartcase!
    

    stands for carriage return. It represents the Return key.

    Now just press \s and it toggles.

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

    :map \s :set smartcase!:set smartcase?
    

提交回复
热议问题