Skip to content

Noorts/Toggler

Repository files navigation


Logo
Toggler

Toggler is a JetBrains IDE Plugin that allows you to quickly toggle words and symbols with a hotkey.
Toggles can be configured from the settings menu.

Plugin downloads Plugin rating Plugin version

FeaturesUsageInstallationConfigurationRoadmapContributeAlternativesAcknowledgementsLicense

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.

Features

  • Customizable through the settings menu.
  • Support for multiple cursors.
  • Support for numerous toggles.
  • Support for partial matches.
  • Limited support for transferring word case.
  • Easy importing and exporting of the JSON configuration.
  • No external dependencies required.

Usage

Select or place your cursor on a word/symbol and press the hotkey (by default Ctrl+Shift+X on Windows or Cmd+Shift+X on macOS) to toggle the word/symbol to the next toggle defined in the configuration file (wrapping around when it reaches the end). The shortcut can be changed from Settings/Preferences -> Keymap -> Plug-ins -> Toggler. The toggle action can also be found as Toggle Word/Symbol in the Edit menu.

The normal action toggles forward (e.g., 1, 2, 3, 1). A reverse toggle action can be used to toggle backwards (e.g., 1, 3, 2, 1). By default it is mapped to Ctrl+Shift+Alt+X on Windows and Cmd+Shift+Opt+X on macOS.

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

Installation

There are four ways to install Toggler:

  • Install from the JetBrains marketplace.
  • Install directly from the plugin marketplace in your JetBrains product. Go to Settings/Preferences -> Plugins -> Marketplace -> Search for "Toggler" -> Install Plugin.
  • Download the jar from a GitHub release and install manually. 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.

Configuration

You can configure the toggles in your IDE by going to Settings/Preferences -> Tools -> Toggler. The Toggler Configuration Menu

Toggles can be added and removed by modifying the JSON inside the configuration menu and subsequently pressing the Apply button. The Import, Export and Reset to Defaults buttons have been added for convenience.

The following boundary characters are used for word/symbol selection internally and thus 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.

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 symbols/words) just like Toggler and includes many other nice features.

Acknowledgements

This plugin has drawn a lot of inspiration from HiDeoo his original versions of toggle plugins/extensions for VSCode and Atom.

License

Toggler is licensed under the MIT license.