Skip to content

Noorts/Toggler

Repository files navigation


Logo
Toggler

A JetBrains IDE plugin that allows you to quickly toggle words with a hotkey.
Toggles can be configured from the settings menu.

Plugin downloads Plugin rating Plugin version

InstallationUsageConfigurationRoadmapVersionsContributeAlternativesAcknowledgementsLicense

Toggler Usage Example


Do you really like Toggler? Consider giving a star on GitHub or leaving a review on the JetBrains marketplace.

Did you find a bug or do you have a feature request? Feel free to open an issue on GitHub.

Installation

  • (Recommended) Install directly from the plugin marketplace in your JetBrains IDE.
    • Go to Settings/Preferences -> Plugins -> Marketplace -> Search for "Toggler" -> Install Plugin.
  • Install manually
    • from the JetBrains marketplace.
    • from GitHub. Download the jar from a GitHub release. Then go to the Settings/Preferences -> Plugins -> Press the ⚙️ (in the top right) -> Choose "Install Plugin from Disk...".
    • Download this repo, build the plugin and install it manually. Also see the "Contribute" section.

Usage

Select or place your cursor on a word and press:

  • Ctrl + Shift + X (Windows and Linux)
  • Cmd + Shift + X (macOS)

If the word matches one of the configured word combinations / toggles, then it will be replaced with the next configured word.

    true -> false
     !== -> ===
      && -> ||
    left -> right
    LEFT -> RIGHT
addClass -> removeClass

See the "Configuration" section below to learn more about the standard word combinations / toggles and how to configure them.

Advanced Usage

The configured toggles "wrap around", which means that if ["true", "false"] is configured, then continually toggling will lead to true -> false -> true -> ....

Word combinations / toggles can contain "any" number of words. Thus, ["public", "private", "protected"] is also supported.

The normal toggle action discussed thus far toggles (i.e., replaces) forward (e.g., 1, 2, 3, 1, ...). Use the reverse toggle action to toggle backwards (e.g., 1, 3, 2, 1, ...). It uses the same keybind as above, but in addition make sure to also hold the Alt (Windows and Linux) or Opt (Linux) key.

Toggler supports toggling with multiple cursors (also known as carets) at the same time.

Toggler has limited support for transferring word case. It supports, full caps (TRUE -> FALSE) and first letter capitalized (True -> False). It defaults back to lowercase in all other cases (true -> false).

The partial matching functionality allows for substrings of words to be toggled. For example, getName can be toggled to setName by placing the cursor anywhere on get and then toggling. The largest match found is prioritised. This means that if you have the following toggles configured ["dev", "prod"] and ["development", "production"], and toggle development, then it will be replaced by production. The partial matching functionality can be bypassed by using your cursor to create a precise selection of the sub word you want to toggle (for example making a selection of dev and then toggling). The partial matching functionality is enabled by default and can be disabled in the configuration menu.

Configuration

Configure the word combinations / toggles and other Toggler settings by going to Settings/Preferences -> Tools -> Toggler in your IDE.

The toggle hotkey / keybind can be changed from Settings/Preferences -> Keymap -> Plug-ins -> Toggler.

The Toggler Configuration Menu

Word combinations / toggles can be added and removed by modifying the JSON-like configuration and subsequently pressing the Apply button. The Import, Export and Reset to Defaults buttons have been added for convenience.

Toggler has a custom mechanism for distinguishing / separating words from each other. Because of that the following boundary characters can't be used inside the toggles ' ', ';', ':', '.', ',', '`', '"', ''', '(', ')', '[', ']', '{', '}', '\t'.

The toggles displayed below are the default ones included with every fresh installment.

[
  ["public", "private", "protected"],
  ["class", "interface"],
  ["extends", "implements"],
  ["import", "export"],
  ["byte", "short", "int", "long", "float", "double"],
  ["String", "Character"],

  ["get", "set"],
  ["add", "remove"],
  ["min", "max"],
  ["pop", "push"],

  ["true", "false"],
  ["yes", "no"],
  ["on", "off"],
  ["0", "1"],
  ["x", "y"],
  ["enable", "disable"],
  ["enabled", "disabled"],
  ["open", "close"],

  ["up", "down"],
  ["left", "right"],
  ["top", "bottom"],
  ["start", "end"],
  ["first", "last"],
  ["before", "after"],
  ["ceil", "floor"],
  ["read", "write"],
  ["show", "hide"],
  ["input", "output"],
  ["dev", "prod"],
  ["development", "production"],
  ["row", "column"],
  ["req", "res"],

  ["&&", "||"],
  ["&", "|"],
  ["<", ">"],
  ["+", "-"],
  ["*", "/"],
  ["++", "--"],
  ["+=", "-="],
  ["*=", "/="],
  ["&=", "|="],
  ["<<=", ">>="],
  ["<=", ">="],
  ["==", "!="],
  ["===", "!=="]
]

Roadmap

The roadmap can be found on the Toggler board.

Versions

See the changelog for an overview of the plugin's versions. Check out the GitHub releases for plugin artifacts and the related source code.

Contribute

  1. Fork and clone the repository.
  2. Set up your development environment (I use IntelliJ IDEA for Toggler's development).
    • Open the project and load the Gradle project. A notification should show up in the bottom right indicating "Gradle build scripts found".
    • Install Java 17 (see javaVersion in gradle.properties) and make sure it is set as the SDK and language level in the project structure settings.
  3. Verify whether you're ready to start development by running the development IDE through Gradle's runIde task. This task should be available under Toggler/Tasks/intellij in the Gradle sidebar. This task will build the plugin and open a development IDE, allowing you to test out the plugin directly.
  4. Make your desired changes in the code.
  5. Verify your changes
    • by running the test Gradle task.
    • (optionally) by running the runPluginVerifier Gradle task to verify whether the plugin is still compatible with the IDE build range configured in gradle.properties.
  6. Commit your changes to your fork.
  7. Create a pull request from your fork to the Noorts/Toggler repository.

Alternatives

  • If you're looking for more text manipulation features, then check out Shifter. Which also includes a dictionary (with custom words) just like Toggler and includes many other nice features.

Acknowledgements

This plugin has drawn inspiration from similar toggle plugins/extensions.

License

Toggler is licensed under the MIT license.