Skip to content

Toggle selected string(s) between camelCase, snake_case and kebab-case.

License

Notifications You must be signed in to change notification settings

wscourge/togglecase

Repository files navigation

ToggleCase

single-tooglecase

Toggle case of the selected string:

  • Ctrl+; Linux
  • ⌘+; MacOS

in the following order:

  1. nocase -> camelCase
  2. camelCase -> snake_case
  3. snake_case -> kebab-case
  4. kebab-case -> camelCase

If you wish to overwrite the default shortcut, search for editor.togglecase.

Features

  • Works with multi-select and multiple carets
  • Per languageId customization

multi-tooglecase

Extension Settings

Only setting present (and configurable for different languages) is regexp of characters that can occur as second and second last in the variable name.

  • togglecase.pattern: "[0-9]|[a-z]|[A-Z]|_|-"

with the following defaults:

  • lowercase a-z letters
  • uppercase A-Z letters
  • digits 0-9
  • hyphen -
  • underscore _

Letters come from the english alphabet.

Custom per-language configuration - let's assume that you're crazy enough to use $ inside your variable names, for example btc_$_price (please don't).

In that case, you could extend the default RegExp with an additional |\$:

"configurationDefaults": {
  "[javascript]": {
    "togglecase.pattern": "[0-9]|[a-z]|[A-Z]|_|-|\$"
  }

It might be useful for some other languages, hence it's configurable.

Known Issues

Toggle works only when caret is at least on the third-last character of the targeted variable.

In the examples below, the | represents current carret(s).

Does not work

{
  "first_nam|e": "Jon",
  "last_nam|e": "Doe",
  "user_nam|e": "jondoe",
  "phone_numbe|r": "555666777"
}

Does work

{
  "first_na|me": "Jon",
  "last_na|me": "Doe",
  "user_na|me": "jondoe",
  "phone_numb|er": "555666777"
}

Fix for this behavior is welcome.

About

Toggle selected string(s) between camelCase, snake_case and kebab-case.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published