Skip to main content

2. Basic coding

This tutorial will teach you the basics of coding with Cursorless.

Step 1

When editing code, we often think in terms of statements, functions, etc. Let's clone a statement: "clone state sit"

Before
After

Step 2

Cursorless tries its best to keep your commands short.

In the following command, we just say "string" once, but Cursorless infers that both targets are strings: "swap string air with whale"

Before
After

Step 3

Great. Let's learn a new action. The "pour" action lets you start editing a new line below any line on your screen: "pour urge"

Before
After

Step 4

Now let's try applying a Cursorless action to the current line: "dedent this"

Before
After

Step 5

Code reuse is a fact of life as a programmer. Cursorless makes this easy with the "bring" command: "bring state urge"

Before
After

Step 6

"bring" also works with two targets just like "swap": "bring blue cap to value red"

Before
After

Step 7

Cursorless tries its best to use its knowledge of programming languages to leave you with syntactically valid code.

Note how it cleans up the comma here: "chuck arg blue vest"

Before
After

Step 8

We introduced a lot of different scopes today. If you're anything like us, you've already forgotten them all.

The important thing to remember is that you can always say "cursorless help" to see a list.

Step 9

That wraps up the Basic coding tutorial. Happy coding 😊.