Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

Convert snake_case to camelCase in Vim

Vim replace operation to convert snake_case to camelCase (credits @Sean C.): %s/_\([a-zA-Z]\)/\u\1/g

What's it for?

Automatically refactor a script's symbol names from snake_case to camelCase.

How to use it?

  • Press ESC to ensure you're in command mode.
  • Press :.
  • Type %s/_\([a-zA-Z]\)/\u\1/g.
  • Press ENTER.

To save the changes, type :, then wq and ENTER.

Credits: https://superuser.com/questions/312073/use-notepad-to-change-under-score-case-to-camelcase#answer-312084

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.