Changing caMelCase to lowercase_underscore

5 views
Skip to first unread message

Frans Grotepass

unread,
Nov 5, 2009, 4:25:16 AM11/5/09
to vim...@googlegroups.com
Hi, I have a number of functions that I need to change from camelCase to
lowercase_undersore notation (Migrating code to coding guidelines).

How can I do a search and replace for something like this? the camelCase
functions all start with a lowercase character.

Best regards,

Frans

Andy Wokula

unread,
Nov 5, 2009, 4:41:45 AM11/5/09
to vim...@googlegroups.com
Frans Grotepass schrieb:

This makes it easy, see below.

> Best regards,
>
> Frans

Try this substitute
:%s/\l\zs\u/_\l&/gc

search for a lower case followed by an upper case char
let the match start at the upper case char

replace with "_" followed by the matched char turned into lower case
:h sub-replace-special
:h :s_flags

--
Andy

Reply all
Reply to author
Forward
0 new messages