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.
Positioning text/code
For the positioning of the text to insert, there are two options:
- Use the
position
property to specify the location where the action should be performed. With this property, you can specify the line number, character position, or a range of lines and characters. - Use the
startPlaceholder
andendPlaceholder
properties to specify the text to search for in the file to determine the location where the action should be performed.
Line position or range
For the position
property, you can use the following values:
number
: The line numbernumber:number
: The start and end line numbernumber,number
: The start line and characternumber,number:number,number
: The start line and character and the end line and character- The
start
andend
keywords can also be used instead of the line numbersstart
will be replaced by the first line numberend
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
Placeholder position
For the startPlaceholder
and endPlaceholder
properties, you specify the text to search for in the file.
Examples:
"startPlaceholder": "// Start of demo1""endPlaceholder": "// End of demo1"
In the file, the placeholders should be defined like this:
// Start of demo1const ext = 'Demo Time';// End of demo1
Highlight text
Highlight text in the editor at a specific location.
// Via position{ "action": "highlight", "path": "<relative path to the file>", "position": "<position>", "zoom": "<zoom level> (optional)"}
// Via placeholders{ "action": "highlight", "path": "<relative path to the file>", "startPlaceholder": "<start placeholder>", "endPlaceholder": "<end placeholder>", "highlightWholeLine": "<highlight whole line (optional, default is true)>", "zoom": "<zoom level> (optional)"}
Position cursor
Position your cursor in the editor at a specific location.
// Via position{ "action": "positionCursor", "path": "<relative path to the file>", "position": "<position>"}
// Via start placeholder{ "action": "positionCursor", "path": "<relative path to the file>", "startPlaceholder": "<start placeholder>",}
Insert text
Insert text in the editor at a specific location.
// Via position{ "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)"}
// Via placeholders{ "action": "insert", "path": "<relative path to the file>", "startPlaceholder": "<start placeholder>", "endPlaceholder": "<end placeholder>", "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.
// Via position{ "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)"}
// Via placeholders{ "action": "replace", "path": "<relative path to the file>", "startPlaceholder": "<start placeholder>", "endPlaceholder": "<end placeholder>", "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// Via position{ "action": "write", "content": "Hello World", "path": "<relative path to the file>", "position": "<position>"}
// Via start placeholder{ "action": "write", "content": "Hello World", "path": "<relative path to the file>", "startPlaceholder": "<start placeholder>",}
Format text
Format the content of the active file.
{ "action": "format"}
Unselect text
Unselect or undo text highlighting in a specific file.
{ "action": "unselect", "path": "<relative path to the file>"}
Delete text
Delete text in the editor at a specific location.
// Via position{ "action": "delete", "path": "<relative path to the file>", "position": "<position>"}
// Via placeholders{ "action": "delete", "path": "<relative path to the file>", "startPlaceholder": "<start placeholder>", "endPlaceholder": "<end placeholder>"}