Created
April 6, 2010 10:32
-
-
Save soh335/357447 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"reference from String::CamelCase | |
function! camelcase#wordsplit(str) | |
return split(a:str, '[_\s]\|[A-Z]\@<![A-Z]\@=\|[A-Z]\@<=[A-Z][a-z]\@=') | |
endfunction | |
function! camelcase#camelize(str) | |
return join(map(split(a:str, '[A-Za-z]\@<=_[A-Za-z]\@='), 'toupper(v:val[0]).v:val[1:]'), '') | |
endfunction | |
function! camelcase#decamelize(str) | |
return join(map(split(a:str, '[A-Z]\@<![A-Z]\@=\|[A-Z]\@<=[A-Z][a-z]\@='), 'tolower(v:val)'), '_') | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment