Adding Code

In this section, we'll cover the topic of adding code in more detail.

Type

The type command is the simplest way to write. type simply inserts text at the current cursor position, so if you say:

type get value

You'll see the text:

get value

Add

While the type command just inserts formatted text, the add command will automatically handle many syntactic details for you. For instance, if you say:

type function get random

Then you'll just get the text:

function get random

But, if you say:

add function get random

Then you'll get the code:

def get_random():
    pass
function getRandom() {
}
void getRandom() {
}

Notice that the same voice command can be used to write code in any language, which means you don't have to memorize the exact syntax for each language you're working with.

Similarly, if you say:

add if

You'll write the code:

if True:
    pass
if (true) {
}
if (true) {
}

Whereas type if will just add the string if at the current cursor position, add if will create a syntactically-correct block of code, without you needing to dictate all of the syntax.

Let's look at another example. If you say:

add class request manager
add parent manager

Then you'll write the code:

class RequestManager(Manager):
    pass
class RequestManager extends Manager {
}
class RequestManager extends Manager {
}

Notice that the default styling of the class name is pascal case, since that's the convention for class names. You can also style the class name differently by specifying symbols and text styling, for instance:

add class underscore camel case request manager

Will produce:

class _requestManager:
    pass
class _requestManager {
}
class _requestManager {
}

You can also use add to write statements, like:

add result plus equals three

Which will write the code:

result += 3
result += 3;
result += 3;

For web languages like HTML and JSX, you can also use commands like:

add tag div
add attribute class equals in quotes hidden

To write the code:

<div class="hidden"></div>

For a list of all possible add commands, check out the Command Reference.