Skip to content

Text actions

Text actions are used to insert, replace, highlight, delete or unselect text in the editor.

Most of these actions make use of the path property to specify the location of the file, and the position property to specify the location where the action should be performed.

For the position property, you can use the following values:

  • number: The line number
  • number:number: The start and end line number
  • number,number: The start line and character
  • number,number:number,number: The start line and character and the end line and character
  • The start and end keywords can also be used instead of the line numbers
    • start will be replaced by the first line number
    • end will be replaced by the last line number

Examples:

"position": "10" // Line 10
"position": "10:20" // Lines 10 to 20
"position": "10,5" // Start line 10, character 5
"position": "10,5:20,10" // Start line 10, character 5 to end line 20, character 10

Highlight text

Highlight text in the editor at a specific location.

{
"action": "highlight",
"path": "<relative path to the file>",
"position": "<position>",
"zoom": "<zoom level> (optional)"
}

Position cursor

Position your cursor in the editor at a specific location.

{
"action": "positionCursor",
"path": "<relative path to the file>",
"position": "<position>"
}

Insert text

Insert text in the editor at a specific location.

{
"action": "insert",
"path": "<relative path to the file>",
"position": "<position>",
"content": "<content of the file> (optional)",
"contentPath": "<relative path to the file in the .demo folder> (optional)",
"lineInsertionDelay": "<delay in milliseconds to insert each line> (optional)"
}

Replace text

Replace text in the editor at a specific location.

{
"action": "replace",
"path": "<relative path to the file>",
"position": "<position>",
"content": "<content of the file> (optional)",
"contentPath": "<relative path to the file in the .demo folder> (optional)",
"lineInsertionDelay": "<delay in milliseconds to insert each line> (optional)"
}

Write single line

Write a single line of text in the editor at the current location or specific location.

// Write to current active position
{
"action": "write",
"content": "Hello World"
}
// Write to a specific position in a file
{
"action": "write",
"content": "Hello World",
"path": "<relative path to the file>",
"position": "<position>"
}

Unselect text

Unselect text in the editor at a specific location.

{
"action": "unselect",
"path": "<relative path to the file>"
}

Delete text

Delete text in the editor at a specific location.

{
"action": "delete",
"path": "<relative path to the file>",
"position": "<position>"
}