Concepts

Let's take a look at a few basic concepts before we go into more depth on different commands.

Actions and Selectors

Nearly all Serenade commands take the same form:

<action> <selector>

An action describes something want to do. Common actions include:

  • go to
  • copy
  • cut
  • delete

A selector describes a block of code you want to manipulate. Common selectors include:

  • line
  • word
  • character
  • block
  • function
  • argument
  • parameter
  • class

Putting them together, some example Serenade commands include:

  • go to line three
  • copy word
  • delete function
  • cut if
  • go to for
  • copy argument
  • delete condition
  • cut character
  • go to method
  • copy block
  • delete return value
  • cut parameter

For a full list of selectors and actions, see the Command Reference

Ordinals

Every selector can also specify an ordinal, either with a prefix like first, second, or third, or a postfix like one, two, or three. The most common use is to jump to a line number:

go to line fifty

You can also apply ordinals to other selectors, like:

delete second class

Or equivalently:

delete class two

Repetition

You can also specify ranges of selectors to delete more than one selector at once. For instance, you can say:

delete lines three to five

Or:

delete two methods

Add

As you've seen, the add action is a common way to add new code. Every add command takes the same form:

add <selector> <text>

For instance, add commands include:

  • add parameter number
  • add function request
  • add import random
  • add class account
  • add if false
  • add return none

Change

The change command essentially combines the delete and type commands, and takes the form:

change <selector> to <text>

For instance, you could say:

change argument to null

In order to change the nearest argument to the string null.