Skip to end of metadata
Go to start of metadata

Overview

In this recipe, we show how to create a simple Ruble command, place it in a menu, and optionally bind it to a key command.

The Code

In the snippet below, we use the Ruby "swapcase" command to switch the case of the selected text. This is the entire Ruble file, though you could ad the menu items and commands to your existing file.

Once created and activated, select text in your document and try the above command. It should flip the case of your text:

Wrap Each Selected Line => wRAP eACH sELECTED lINE

Using Environment Variables

Rather than reading from stdin (note the "input = :selection, :word" up top), you could also use an environment variable: