Camel case to underscore-separated and back

From: Brian Schott <>
Date: Tue, 09 Mar 2010 23:51:40 -0800

I was playing around a bit with the lua shell tonight and came up with
the following:

-- camel case to underscores
keys.cU = {function()
buffer:replace_sel(buffer:get_sel_text():gsub("(%u)", function(s) return
"_"..string.lower(s) end)) end}

-- underscores to camel case
keys.cC = {function()
buffer:replace_sel(buffer:get_sel_text():gsub("_(%w)", string.upper)) end}

Select some text, hit the key combo, and watch in amazement as
text_that_looks_like_this turns into textThatLooksLikeThis

- Brian
Received on Wed 10 Mar 2010 - 02:51:40 EST

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 11:39:59 EST