Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save msmikesm/88e0fd53b61e108343f7abe41534f5a5 to your computer and use it in GitHub Desktop.
Save msmikesm/88e0fd53b61e108343f7abe41534f5a5 to your computer and use it in GitHub Desktop.
Convert all occurrences of snake_case to camelCase in VS Code. Windows/Linux walk-through here: https://youtu.be/vlHel1fN5_A

Convert snake_case to camelCase in VS Code

  • Press CTRL-H ( ⌥⌘F on Mac ).
  • Press ALT-R ( ⌥⌘R on Mac ).
  • Type _([a-zA-Z]).
  • Press TAB and type $1.
  • Press ALT-ENTER ( ⌥ENTER on Mac ).
  • Press F1 and type upper, then press ENTER.
  • Press CTRL-ALT-ENTER ( ⌥ENTER on Mac ).

Explanation

VS Code (and Atom) currently use JavaScript-style regular expressions for the find/replace feature so the replace operation doesn't support switches that are available in other editors like Vim (example: \u\1) or Sublime Text (example: $1-\L$1\E).

The workflow above will achieve the same results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment