16 Oct 2012 pedro   » (Journeyer)

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!

Syndicated 2012-10-16 19:05:03 from off by one

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!