Deleting entry: pedro/2012/10/16/0

Password:

Please confirm the deletion of this entry.


[Trackback URL for this entry] Sometimes I can be a little too sensitive...:

Case-sensitivity is a given in most *NIX and programming environments. But in your editors and tools, case sensitivity is a double-edged sword. Sometimes it's nice to have case-insensitive search so you can find every matching sequence, but just as often I end up getting "too many hits". And doing find and replace insensitively can be really annoying. If only there was a smarter way to manage case!

There is. vim has a neat feature called "smartcase" that searches insensitively if you use all lower-case, but searches case-sensitively if you include any capital letters in your search. So,

/foo

... would find "foo", "Foo", "fOO", etc., but

/Foo

... would only match on "Foo".

To enable smartcase, you also need to enable case-insensitivity. You can put this in your .vimrc:

set ignorecase " Do case insensitive matching

set smartcase " I'm sensitive, but not too sensitive.

However, if you want to do this on a case by case basis, you can do this in vim at runtime with :set ignorecase and :set smartcase. (:set nosmartcase and :set noignorecase will undo the option.) Happy hacking!

Filed under:



[Main]

Unless otherwise noted, all content licensed by Peter A. H. Peterson
under a Creative Commons License.